CREATE TABLE "domains" ( "id" varchar(255) PRIMARY KEY, "friendly_name" varchar(255), "support_email" varchar(255), "created_at" datetime, "updated_at" datetime ); CREATE TABLE "tenants" ( "id" int PRIMARY KEY, "name" varchar(255), "domain_id" varchar(255) FOREIGN KEY("domain_id") REFERENCES "domains" ("id"), "created_at" datetime, "updated_at" datetime ); CREATE TABLE "resource_types" ( "id" int PRIMARY KEY, "name" varchar(255), "domain_id" varchar(255) FOREIGN KEY("domain_id") REFERENCES "domains" ("id"), "created_at" datetime, "updated_at" datetime ); CREATE TABLE "role_templates" ( "id" int PRIMARY KEY, "name" varchar(255), "domain_id" varchar(255) FOREIGN KEY("domain_id") REFERENCES "domains" ("id"), "created_at" datetime, "updated_at" datetime ); CREATE TABLE "actions" ( "id" int PRIMARY KEY, "name" varchar(255), "resource_type_id" int FOREIGN KEY("resource_type_id") REFERENCES "resource_types" ("id"), "created_at" datetime, "updated_at" datetime ); CREATE TABLE "role_template_permissions" ( "id" int PRIMARY KEY, "resource_path" varchar(255), "action_id" int FOREIGN KEY("action_id") REFERENCES "actions" ("id"), "allow_deny" varchar(255), "role_template_id" int FOREIGN KEY("role_template_id") REFERENCES "role_templates" ("id"), "created_at" datetime, "updated_at" datetime ); CREATE TABLE "roles" ( "id" int PRIMARY KEY, "name" varchar(255), "tenant_id" int FOREIGN KEY("tenant_id") REFERENCES "tenants" ("id"), "inherits_role_id" int FOREIGN KEY("inherits_role_id") REFERENCES "roles" ("id"), "role_template_id" int FOREIGN KEY("role_template_id") REFERENCES "role_templates" ("id"), "created_at" datetime, "updated_at" datetime ); CREATE TABLE "role_permissions" ( "id" int PRIMARY KEY, "resource_path" varchar(255), "action_id" int FOREIGN KEY("action_id") REFERENCES "actions" ("id"), "allow_deny" varchar(255), "role_id" int FOREIGN KEY("role_id") REFERENCES "roles" ("id"), "created_at" datetime, "updated_at" datetime ); CREATE TABLE "role_trust" ( "id" int PRIMARY KEY, "usertype" varchar(255), "identifier" varchar(255), "role_id" int FOREIGN KEY("role_id") REFERENCES "roles" ("id"), "created_at" datetime, "updated_at" datetime );