summaryrefslogtreecommitdiff
path: root/coverage/sqldata.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-08-06 07:00:35 -0400
committerNed Batchelder <ned@nedbatchelder.com>2019-08-06 07:00:35 -0400
commit57a637f22b14eb50dfda53093f6674edc7c7f4f6 (patch)
tree49a1362a9efffa68e5781bde545b494b587a2fe8 /coverage/sqldata.py
parent2d7ad503f60f982d6431870663238a76e5a28b56 (diff)
downloadpython-coveragepy-git-57a637f22b14eb50dfda53093f6674edc7c7f4f6.tar.gz
Foreign keys
Diffstat (limited to 'coverage/sqldata.py')
-rw-r--r--coverage/sqldata.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/coverage/sqldata.py b/coverage/sqldata.py
index 4a00414d..7e3a0390 100644
--- a/coverage/sqldata.py
+++ b/coverage/sqldata.py
@@ -27,7 +27,7 @@ from coverage.numbits import nums_to_numbits, numbits_to_nums, merge_numbits
os = isolate_module(os)
-SCHEMA_VERSION = 4
+SCHEMA_VERSION = 5
SCHEMA = """
CREATE TABLE coverage_schema (
@@ -38,6 +38,7 @@ CREATE TABLE coverage_schema (
-- 2: Added contexts in 5.0a3.
-- 3: Replaced line table with line_map table.
-- 4: Changed line_map.bitmap to line_map.numbits.
+ -- 5: Added foreign key declarations.
);
CREATE TABLE meta (
@@ -66,6 +67,8 @@ CREATE TABLE line_map (
file_id integer, -- foreign key to `file`.
context_id integer, -- foreign key to `context`.
numbits blob, -- see the numbits functions in coverage.numbits
+ foreign key (file_id) references file (id),
+ foreign key (context_id) references context (id),
unique(file_id, context_id)
);
@@ -75,13 +78,16 @@ CREATE TABLE arc (
context_id integer, -- foreign key to `context`.
fromno integer, -- line number jumped from.
tono integer, -- line number jumped to.
+ foreign key (file_id) references file (id),
+ foreign key (context_id) references context (id),
unique(file_id, context_id, fromno, tono)
);
CREATE TABLE tracer (
-- A row per file indicating the tracer used for that file.
file_id integer primary key,
- tracer text
+ tracer text,
+ foreign key (file_id) references file (id)
);
"""