11 lines
394 B
SQL
11 lines
394 B
SQL
-- User roles table for role-based access control
|
|
CREATE TABLE IF NOT EXISTS app.user_roles (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
user_id BIGINT NOT NULL REFERENCES app.users(id),
|
|
role VARCHAR(50) NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
CONSTRAINT uq_user_role UNIQUE (user_id, role)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_user_roles_user_id ON app.user_roles(user_id);
|