beteran-server-service/migrations/202206191210_role_resource_action/up.sql
2022-08-06 11:37:51 +00:00

15 lines
557 B
SQL

CREATE TABLE IF NOT EXISTS role_resource_actions (
role_id UUID NOT NULL,
resource_action_id UUID NOT NULL,
created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
PRIMARY KEY (role_id, resource_action_id),
CONSTRAINT fk_role_actions_role_id
FOREIGN KEY(role_id)
REFERENCES roles(id),
CONSTRAINT fk_role_actions_resource_action_id
FOREIGN KEY(resource_action_id)
REFERENCES resource_actions(id)
);
CREATE INDEX idx_role_resource_actions_role_id ON role_resource_actions (role_id);