Files
geo/server/migrations/20260331100002_create_tenant_memberships.up.sql
T

11 lines
466 B
SQL
Raw Normal View History

CREATE TABLE tenant_memberships (
id BIGSERIAL PRIMARY KEY,
tenant_id BIGINT NOT NULL REFERENCES tenants(id),
user_id BIGINT NOT NULL REFERENCES users(id),
tenant_role VARCHAR(20) NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMPTZ
);
CREATE UNIQUE INDEX uk_tenant_user_active ON tenant_memberships(tenant_id, user_id) WHERE deleted_at IS NULL;