WIP: Add a migration for project membmership

Signed-off-by: Nikolai Rodionov <iam@allanger.xyz>
This commit is contained in:
2026-05-21 16:48:12 +02:00
parent 4782caaca0
commit 06afab3f5a
3 changed files with 44 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
DROP INDEX IF EXISTS idx_project_memberships_project;
DROP INDEX IF EXISTS idx_project_memberships_user;
DROP TABLE IF EXISTS project_memberships;
DROP TYPE IF EXISTS membership_status;
DROP TYPE IF EXISTS project_role;

View File

@@ -0,0 +1,35 @@
CREATE TYPE project_role AS ENUM (
'member',
'admin',
'owner'
);
CREATE TYPE membership_status AS ENUM (
'invited',
'active',
'suspended'
);
CREATE TABLE project_memberships (
project_uuid UUID NOT NULL
REFERENCES projects(uuid)
ON DELETE CASCADE,
user_uuid UUID NOT NULL
REFERENCES accounts(uuid)
ON DELETE CASCADE,
role project_role NOT NULL,
status membership_status NOT NULL DEFAULT 'active',
invited_by UUID NULL
REFERENCES accounts(uuid),
joined_at TIMESTAMP NULL,
PRIMARY KEY (project_uuid, user_uuid)
);
CREATE INDEX idx_project_memberships_user
ON project_memberships(user_uuid);
CREATE INDEX idx_project_memberships_project
ON project_memberships(project_uuid);