CREATE TYPE raid_builder.raid_group_permission_type AS ENUM ( 'ADMIN', 'LEADER', 'RAIDER' );


CREATE TABLE IF NOT EXISTS raid_builder.raid_group_permission(
	raid_group_permission_id uuid PRIMARY KEY,
	account_id uuid REFERENCES raid_builder.account(account_id) NOT NULL,
	raid_group_id uuid REFERENCES raid_builder.raid_group(raid_group_id) NOT NULL,
	permission raid_builder.raid_group_permission_type NOT NULL,

	--Auditing
	modified_by uuid NOT NULL,
	modified_date timestamptz,
	created_by uuid NOT NULL,
	created_date timestamptz NOT NULL
);

CREATE INDEX idx_raid_group_permission_account_id ON raid_builder.raid_group_permission(account_id);
CREATE INDEX idx_raid_group_permission_raid_group_id ON raid_builder.raid_group_permission(raid_group_id);

GRANT ALL ON TABLE raid_builder.raid_group_permission TO raid_builder;
