aboutsummaryrefslogtreecommitdiff
path: root/migrations/auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-11-10 10:42:25 +0300
committerFrederick Muriuki Muriithi2022-11-10 10:42:25 +0300
commit8972ec32949b7ad0c87043da1ac091d7404737a5 (patch)
tree28139e6227cf5fe917d4d2e44213e304b999326a /migrations/auth
parent104703d29592496dd373668791a0c36cef70dde7 (diff)
downloadgenenetwork3-8972ec32949b7ad0c87043da1ac091d7404737a5.tar.gz
Migrations: Add migration for 'phenotype_resources' table
* migrations/auth/20221110_03_ka3W0-create-phenotype-resources-table.py: new migration * tests/unit/auth/test_create_table_migrations.py: test for new migration
Diffstat (limited to 'migrations/auth')
-rw-r--r--migrations/auth/20221110_03_ka3W0-create-phenotype-resources-table.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/migrations/auth/20221110_03_ka3W0-create-phenotype-resources-table.py b/migrations/auth/20221110_03_ka3W0-create-phenotype-resources-table.py
new file mode 100644
index 0000000..d241f77
--- /dev/null
+++ b/migrations/auth/20221110_03_ka3W0-create-phenotype-resources-table.py
@@ -0,0 +1,23 @@
+"""
+Create 'phenotype_resources' table
+
+NOTE: A "phenotype resource" can only ever be linked to one and only one "resource object"
+ A "resource object" can be linked to one or more "phenotype resource".
+"""
+
+from yoyo import step
+
+__depends__ = {'20221110_02_z1dWf-create-mrna-resources-table'}
+
+steps = [
+ step(
+ """
+ CREATE TABLE IF NOT EXISTS phenotype_resources(
+ resource_id TEXT NOT NULL,
+ trait_id TEXT NOT NULL UNIQUE,
+ PRIMARY KEY(resource_id, trait_id),
+ FOREIGN KEY(resource_id) REFERENCES resources(resource_id)
+ ) WITHOUT ROWID
+ """,
+ "DROP TABLE IF EXISTS phenotype_resources")
+]