aboutsummaryrefslogtreecommitdiff
path: root/migrations/auth/20230216_01_dgWjv-create-linked-group-data-table.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-02-16 12:24:23 +0300
committerFrederick Muriuki Muriithi2023-02-21 16:24:30 +0300
commit08e8e36e256d1893967c98b366395279b39c1e72 (patch)
treeb5784f9cf52bfdf9e8c64b7fcab4189fc5b4bb16 /migrations/auth/20230216_01_dgWjv-create-linked-group-data-table.py
parent283e7f08701ed80cdfeb8773df38c0c30227a10c (diff)
downloadgenenetwork3-08e8e36e256d1893967c98b366395279b39c1e72.tar.gz
auth: migrations: Link to data in main db
Provide the `linked_group_data` table to be used to link to data in the main database. Update the `mrna_resources`, `genotype_resources` and `phenotype_resources` tables to rely on the `linked_group_data` table.
Diffstat (limited to 'migrations/auth/20230216_01_dgWjv-create-linked-group-data-table.py')
-rw-r--r--migrations/auth/20230216_01_dgWjv-create-linked-group-data-table.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/migrations/auth/20230216_01_dgWjv-create-linked-group-data-table.py b/migrations/auth/20230216_01_dgWjv-create-linked-group-data-table.py
new file mode 100644
index 0000000..b54942c
--- /dev/null
+++ b/migrations/auth/20230216_01_dgWjv-create-linked-group-data-table.py
@@ -0,0 +1,24 @@
+"""
+Create linked_group_data table
+"""
+
+from yoyo import step
+
+__depends__ = {'20230210_02_lDK14-create-system-admin-role'}
+
+steps = [
+ step(
+ """
+ CREATE TABLE IF NOT EXISTS linked_group_data(
+ group_id TEXT NOT NULL,
+ dataset_or_trait_id TEXT NOT NULL,
+ name TEXT NOT NULL,
+ type TEXT NOT NULL,
+ PRIMARY KEY(group_id, dataset_or_trait_id),
+ FOREIGN KEY (group_id) REFERENCES groups(group_id)
+ ON UPDATE CASCADE ON DELETE RESTRICT,
+ CHECK (type IN ('mRNA', 'Genotype', 'Phenotype'))
+ ) WITHOUT ROWID
+ """,
+ "DROP TABLE IF EXISTS linked_group_data")
+]