fix(store): enforce sighting finding id invariant
This commit is contained in:
@@ -163,7 +163,7 @@ MIGRATIONS: Dict[int, str] = {
|
|||||||
2: """
|
2: """
|
||||||
CREATE TABLE IF NOT EXISTS finding_sightings (
|
CREATE TABLE IF NOT EXISTS finding_sightings (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
finding_id INTEGER REFERENCES findings(id) ON DELETE CASCADE,
|
finding_id INTEGER NOT NULL REFERENCES findings(id) ON DELETE CASCADE,
|
||||||
run_id INTEGER REFERENCES research_runs(id) ON DELETE CASCADE,
|
run_id INTEGER REFERENCES research_runs(id) ON DELETE CASCADE,
|
||||||
topic_id INTEGER REFERENCES topics(id) ON DELETE CASCADE,
|
topic_id INTEGER REFERENCES topics(id) ON DELETE CASCADE,
|
||||||
source TEXT NOT NULL,
|
source TEXT NOT NULL,
|
||||||
|
|||||||
@@ -451,9 +451,14 @@ def test_init_db_creates_finding_sightings_table(temp_db):
|
|||||||
table = conn.execute(
|
table = conn.execute(
|
||||||
"SELECT name FROM sqlite_master WHERE type='table' AND name='finding_sightings'"
|
"SELECT name FROM sqlite_master WHERE type='table' AND name='finding_sightings'"
|
||||||
).fetchone()
|
).fetchone()
|
||||||
|
columns = {
|
||||||
|
row[1]: row[3]
|
||||||
|
for row in conn.execute("PRAGMA table_info(finding_sightings)").fetchall()
|
||||||
|
}
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
assert table is not None
|
assert table is not None
|
||||||
|
assert columns["finding_id"] == 1
|
||||||
|
|
||||||
|
|
||||||
def test_store_findings_records_sightings_for_new_findings(temp_db):
|
def test_store_findings_records_sightings_for_new_findings(temp_db):
|
||||||
|
|||||||
Reference in New Issue
Block a user