about summary refs log tree commit diff
path: root/migrations
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-02-07 13:00:56 +0300
committerFrederick Muriuki Muriithi2023-02-07 13:01:27 +0300
commit87586bd5270140bf52d39d3dc61c754dd13d4391 (patch)
tree86e4c36ce0fc3334bfbf6d421efb070dd5f3cfd2 /migrations
parent3cc5e7b57b0ca9bd5143d746022cb69349023a68 (diff)
downloadgenenetwork3-87586bd5270140bf52d39d3dc61c754dd13d4391.tar.gz
auth: groups: Enable users to request to join group.
Diffstat (limited to 'migrations')
-rw-r--r--migrations/auth/20230207_01_r0bkZ-create-group-requests-table.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/migrations/auth/20230207_01_r0bkZ-create-group-requests-table.py b/migrations/auth/20230207_01_r0bkZ-create-group-requests-table.py
new file mode 100644
index 0000000..d2cf786
--- /dev/null
+++ b/migrations/auth/20230207_01_r0bkZ-create-group-requests-table.py
@@ -0,0 +1,27 @@
+"""
+Create group_requests table
+"""
+
+from yoyo import step
+
+__depends__ = {'20230116_01_KwuJ3-rework-privileges-schema'}
+
+steps = [
+    step(
+        """
+        CREATE TABLE IF NOT EXISTS group_requests(
+            request_id TEXT NOT NULL,
+            group_id TEXT NOT NULL,
+            requester_id TEXT NOT NULL,
+            request_type TEXT NOT NULL,
+            timestamp REAL NOT NULL,
+            message TEXT,
+            PRIMARY KEY(request_id, group_id),
+            FOREIGN KEY(group_id) REFERENCES groups(group_id)
+            ON UPDATE CASCADE ON DELETE CASCADE,
+            FOREIGN KEY (requester_id) REFERENCES users(user_id)
+            ON UPDATE CASCADE ON DELETE CASCADE
+        ) WITHOUT ROWID
+        """,
+        "DROP TABLE IF EXISTS group_requests")
+]