rhythm-backend/migrations/0004_create_org_membership_table.sql
Dmitri a846093fbf
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 1m30s
initial work for organizations
2026-05-04 23:30:41 +02:00

14 lines
410 B
SQL

CREATE TYPE org_role AS ENUM ('owner', 'admin', 'member', 'viewer');
CREATE TABLE org_memberships (
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
org_id UUID NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
role org_role NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (user_id, org_id)
);