CREATE TABLE IF NOT EXISTS member_permissions (
  member_id                 UUID NOT NULL,
  role_resource_action_id   UUID NOT NULL,
  created_at                BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
  PRIMARY KEY (member_id, role_resource_action_id),
  CONSTRAINT fk_member_permissions_member_id
    FOREIGN KEY(member_id) 
	    REFERENCES members(id),
  CONSTRAINT fk_member_permissions_role_id
    FOREIGN KEY(role_id) 
	    REFERENCES roles(id)
);

CREATE INDEX idx_member_permissions_role_id ON member_permissions (role_id);
CREATE INDEX idx_member_permissions_member_id ON member_permissions (member_id);
