aboutsummaryrefslogtreecommitdiff
path: root/migrations/auth/20230216_01_dgWjv-create-linked-group-data-table.py
blob: b54942c957d1e3c5c14f3f3fa0d6438454485be1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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")
]