Create identity__user table CREATE TABLE identity__user ( id uuid PRIMARY KEY, username varchar(128) NOT NULL, display_name varchar(256) NOT NULL, email varchar(320), enabled boolean NOT NULL DEFAULT true, ext jsonb NOT NULL DEFAULT '{}'::jsonb, created_at timestamptz NOT NULL, created_by varchar(128) NOT NULL, updated_at timestamptz NOT NULL, updated_by varchar(128) NOT NULL, version bigint NOT NULL DEFAULT 0 ); CREATE UNIQUE INDEX identity__user_username_uk ON identity__user (username); CREATE INDEX identity__user_ext_gin ON identity__user USING GIN (ext jsonb_path_ops); DROP TABLE identity__user; Create identity__role table CREATE TABLE identity__role ( id uuid PRIMARY KEY, code varchar(64) NOT NULL, name varchar(256) NOT NULL, description text, ext jsonb NOT NULL DEFAULT '{}'::jsonb, created_at timestamptz NOT NULL, created_by varchar(128) NOT NULL, updated_at timestamptz NOT NULL, updated_by varchar(128) NOT NULL, version bigint NOT NULL DEFAULT 0 ); CREATE UNIQUE INDEX identity__role_code_uk ON identity__role (code); CREATE INDEX identity__role_ext_gin ON identity__role USING GIN (ext jsonb_path_ops); DROP TABLE identity__role; Create identity__user_role join table CREATE TABLE identity__user_role ( id uuid PRIMARY KEY, user_id uuid NOT NULL REFERENCES identity__user(id) ON DELETE CASCADE, role_id uuid NOT NULL REFERENCES identity__role(id) ON DELETE CASCADE, created_at timestamptz NOT NULL, created_by varchar(128) NOT NULL, updated_at timestamptz NOT NULL, updated_by varchar(128) NOT NULL, version bigint NOT NULL DEFAULT 0 ); CREATE UNIQUE INDEX identity__user_role_uk ON identity__user_role (user_id, role_id); DROP TABLE identity__user_role;