aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-11-10 10:33:43 +0300
committerFrederick Muriuki Muriithi2022-11-10 10:33:43 +0300
commit104703d29592496dd373668791a0c36cef70dde7 (patch)
treeee8c827a12cebeb3d4ad49149787e112e7e32296
parenta30b8e2d2ce14896e2a43304f684eb88876c8e8c (diff)
downloadgenenetwork3-104703d29592496dd373668791a0c36cef70dde7.tar.gz
Migrations: Add migration for mrna_resources table
* migrations/auth/20221110_02_z1dWf-create-mrna-resources-table.py: new migration * tests/unit/auth/test_create_table_migrations.py: test for new migration
-rw-r--r--migrations/auth/20221110_02_z1dWf-create-mrna-resources-table.py22
-rw-r--r--tests/unit/auth/test_create_table_migrations.py3
2 files changed, 24 insertions, 1 deletions
diff --git a/migrations/auth/20221110_02_z1dWf-create-mrna-resources-table.py b/migrations/auth/20221110_02_z1dWf-create-mrna-resources-table.py
new file mode 100644
index 0000000..0959116
--- /dev/null
+++ b/migrations/auth/20221110_02_z1dWf-create-mrna-resources-table.py
@@ -0,0 +1,22 @@
+"""
+Create 'mrna_resources' table
+
+NOTE: One "mRNA dataset" should only ever be linked to one and only one resource object.
+ One "resource object" should only ever be linked to one and only one "mRNA dataset".
+"""
+
+from yoyo import step
+
+__depends__ = {'20221110_01_WtZ1I-create-resources-table'}
+
+steps = [
+ step(
+ """
+ CREATE TABLE IF NOT EXISTS mrna_resources(
+ resource_id TEXT PRIMARY KEY,
+ dataset_id TEXT NOT NULL UNIQUE,
+ FOREIGN KEY(resource_id) REFERENCES resources(resource_id)
+ ) WITHOUT ROWID
+ """,
+ "DROP TABLE IF EXISTS mrna_resources")
+]
diff --git a/tests/unit/auth/test_create_table_migrations.py b/tests/unit/auth/test_create_table_migrations.py
index 024f04b..c8184e5 100644
--- a/tests/unit/auth/test_create_table_migrations.py
+++ b/tests/unit/auth/test_create_table_migrations.py
@@ -15,7 +15,8 @@ migrations_and_tables = (
("20221108_01_CoxYh-create-the-groups-table.py", "groups"),
("20221108_02_wxTr9-create-privileges-table.py", "privileges"),
("20221108_03_Pbhb1-create-resource-categories-table.py", "resource_categories"),
- ("20221110_01_WtZ1I-create-resources-table.py", "resources"))
+ ("20221110_01_WtZ1I-create-resources-table.py", "resources"),
+ ("20221110_02_z1dWf-create-mrna-resources-table.py", "mrna_resources"))
@pytest.mark.unit_test
@pytest.mark.parametrize("migration_file,the_table", migrations_and_tables)