beteran-server-service/migrations/202206201400_member_role/up.sql

16 lines
563 B
MySQL
Raw Permalink Normal View History

2022-08-06 11:37:51 +00:00
CREATE TABLE IF NOT EXISTS member_roles (
member_id UUID NOT NULL,
role_id UUID NOT NULL,
created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
PRIMARY KEY (member_id, role_id),
CONSTRAINT fk_member_roles_role_id
FOREIGN KEY(role_id)
REFERENCES roles(id),
CONSTRAINT fk_member_roles_member_id
FOREIGN KEY(member_id)
REFERENCES members(id)
);
CREATE INDEX idx_member_roles_role_id ON member_roles (role_id);
CREATE INDEX idx_member_roles_member_id ON member_roles (member_id);