From 9b94ec57c504acb6ef815d134144c4c357c71f17 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 8 Feb 2023 17:24:35 +0300 Subject: auth: groups: handle join requests. --- ...07_01_r0bkZ-create-group-join-requests-table.py | 28 ++++++++++++++++++++++ ...0230207_01_r0bkZ-create-group-requests-table.py | 27 --------------------- 2 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 migrations/auth/20230207_01_r0bkZ-create-group-join-requests-table.py delete mode 100644 migrations/auth/20230207_01_r0bkZ-create-group-requests-table.py (limited to 'migrations') diff --git a/migrations/auth/20230207_01_r0bkZ-create-group-join-requests-table.py b/migrations/auth/20230207_01_r0bkZ-create-group-join-requests-table.py new file mode 100644 index 0000000..6b06a64 --- /dev/null +++ b/migrations/auth/20230207_01_r0bkZ-create-group-join-requests-table.py @@ -0,0 +1,28 @@ +""" +Create group_requests table +""" + +from yoyo import step + +__depends__ = {'20230116_01_KwuJ3-rework-privileges-schema'} + +steps = [ + step( + """ + CREATE TABLE IF NOT EXISTS group_join_requests( + request_id TEXT NOT NULL, + group_id TEXT NOT NULL, + requester_id TEXT NOT NULL, + timestamp REAL NOT NULL, + status TEXT NOT NULL DEFAULT 'PENDING', + 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, + CHECK (status IN ('PENDING', 'ACCEPTED', 'REJECTED')) + ) WITHOUT ROWID + """, + "DROP TABLE IF EXISTS group_join_requests") +] diff --git a/migrations/auth/20230207_01_r0bkZ-create-group-requests-table.py b/migrations/auth/20230207_01_r0bkZ-create-group-requests-table.py deleted file mode 100644 index d2cf786..0000000 --- a/migrations/auth/20230207_01_r0bkZ-create-group-requests-table.py +++ /dev/null @@ -1,27 +0,0 @@ -""" -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") -] -- cgit v1.2.3