diff --git a/paper_atlas/curation/annotations.py b/paper_atlas/curation/annotations.py index a8fa0d8..f6e593c 100644 --- a/paper_atlas/curation/annotations.py +++ b/paper_atlas/curation/annotations.py @@ -78,7 +78,7 @@ def _url(value): def _require(conn): - if not available(conn): + if not available(conn) or not conn.execute('SELECT 1 FROM schema_migrations WHERE name=?', (MIGRATION,)).fetchone(): raise RuntimeError('Run paper-atlas annotate init explicitly before adding annotations') diff --git a/tests/test_annotations.py b/tests/test_annotations.py index 2f4dcb7..eba7a54 100644 --- a/tests/test_annotations.py +++ b/tests/test_annotations.py @@ -59,6 +59,13 @@ class AnnotationTests(unittest.TestCase): self.assertTrue(initialize(self.c)); self.assertFalse(initialize(self.c)) self.assertEqual(len(schema.inspect(self.c)), 22) + def test_unmarked_table_cannot_receive_assertions(self): + initialize(self.c) + self.c.execute("DELETE FROM schema_migrations WHERE name='annotation_events_v1'") + with self.assertRaisesRegex(RuntimeError, 'init explicitly'): + self.add() + self.assertEqual(self.c.execute('SELECT count(*) FROM annotation_events').fetchone()[0], 0) + def test_types_tags_and_platform_labels_are_independent_and_queryable(self): initialize(self.c) self.add()