diff --git a/dashboard/drizzle/0000_square_moondragon.sql b/dashboard/drizzle/0000_square_moondragon.sql new file mode 100644 index 0000000..5400fe7 --- /dev/null +++ b/dashboard/drizzle/0000_square_moondragon.sql @@ -0,0 +1,484 @@ +-- Current sql file was generated after introspecting the database +-- If you want to run this migration please uncomment this code before executing migrations +/* +CREATE TABLE "schema_migration" ( + "version" varchar(48) NOT NULL, + "version_self" integer DEFAULT 0 NOT NULL +); +--> statement-breakpoint +CREATE TABLE "identity_credentials" ( + "id" uuid PRIMARY KEY NOT NULL, + "config" jsonb NOT NULL, + "identity_credential_type_id" uuid NOT NULL, + "identity_id" uuid NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "nid" uuid, + "version" integer DEFAULT 0 NOT NULL +); +--> statement-breakpoint +CREATE TABLE "identity_credential_types" ( + "id" uuid PRIMARY KEY NOT NULL, + "name" varchar(32) NOT NULL +); +--> statement-breakpoint +CREATE TABLE "selfservice_login_flows" ( + "id" uuid PRIMARY KEY NOT NULL, + "request_url" text NOT NULL, + "issued_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "expires_at" timestamp NOT NULL, + "active_method" varchar(32) NOT NULL, + "csrf_token" varchar(255) NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "forced" boolean DEFAULT false NOT NULL, + "type" varchar(16) DEFAULT 'browser' NOT NULL, + "ui" jsonb, + "nid" uuid, + "requested_aal" varchar(4) DEFAULT 'aal1' NOT NULL, + "internal_context" jsonb NOT NULL, + "oauth2_login_challenge" uuid, + "oauth2_login_challenge_data" text, + "state" varchar(255), + "submit_count" integer DEFAULT 0 NOT NULL, + "organization_id" uuid +); +--> statement-breakpoint +CREATE TABLE "networks" ( + "id" uuid PRIMARY KEY NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL +); +--> statement-breakpoint +CREATE TABLE "selfservice_registration_flows" ( + "id" uuid PRIMARY KEY NOT NULL, + "request_url" text NOT NULL, + "issued_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "expires_at" timestamp NOT NULL, + "active_method" varchar(32) NOT NULL, + "csrf_token" varchar(255) NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "type" varchar(16) DEFAULT 'browser' NOT NULL, + "ui" jsonb, + "nid" uuid, + "internal_context" jsonb NOT NULL, + "oauth2_login_challenge" uuid, + "oauth2_login_challenge_data" text, + "state" varchar(255), + "submit_count" integer DEFAULT 0 NOT NULL, + "organization_id" uuid +); +--> statement-breakpoint +CREATE TABLE "identities" ( + "id" uuid PRIMARY KEY NOT NULL, + "schema_id" varchar(2048) NOT NULL, + "traits" jsonb NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "nid" uuid, + "state" varchar(255) DEFAULT 'active' NOT NULL, + "state_changed_at" timestamp, + "metadata_public" jsonb, + "metadata_admin" jsonb, + "available_aal" varchar(4), + "organization_id" uuid +); +--> statement-breakpoint +CREATE TABLE "identity_credential_identifiers" ( + "id" uuid PRIMARY KEY NOT NULL, + "identifier" varchar(255) NOT NULL, + "identity_credential_id" uuid NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "nid" uuid, + "identity_credential_type_id" uuid NOT NULL +); +--> statement-breakpoint +CREATE TABLE "identity_verifiable_addresses" ( + "id" uuid PRIMARY KEY NOT NULL, + "status" varchar(16) NOT NULL, + "via" varchar(16) NOT NULL, + "verified" boolean NOT NULL, + "value" varchar(400) NOT NULL, + "verified_at" timestamp, + "identity_id" uuid NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "nid" uuid +); +--> statement-breakpoint +CREATE TABLE "courier_messages" ( + "id" uuid PRIMARY KEY NOT NULL, + "type" integer NOT NULL, + "status" integer NOT NULL, + "body" text NOT NULL, + "subject" varchar(255) NOT NULL, + "recipient" varchar(255) NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "template_type" varchar(255) DEFAULT '' NOT NULL, + "template_data" "bytea", + "nid" uuid, + "send_count" integer DEFAULT 0 NOT NULL, + "channel" varchar(32) +); +--> statement-breakpoint +CREATE TABLE "selfservice_errors" ( + "id" uuid PRIMARY KEY NOT NULL, + "errors" jsonb NOT NULL, + "seen_at" timestamp, + "was_seen" boolean NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "csrf_token" varchar(255) DEFAULT '' NOT NULL, + "nid" uuid +); +--> statement-breakpoint +CREATE TABLE "selfservice_verification_flows" ( + "id" uuid PRIMARY KEY NOT NULL, + "request_url" text NOT NULL, + "issued_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "expires_at" timestamp NOT NULL, + "csrf_token" varchar(255) NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "type" varchar(16) DEFAULT 'browser' NOT NULL, + "state" varchar(255) DEFAULT 'show_form' NOT NULL, + "active_method" varchar(32), + "ui" jsonb, + "nid" uuid, + "submit_count" integer DEFAULT 0 NOT NULL, + "oauth2_login_challenge" text, + "session_id" uuid, + "identity_id" uuid, + "authentication_methods" json +); +--> statement-breakpoint +CREATE TABLE "selfservice_settings_flows" ( + "id" uuid PRIMARY KEY NOT NULL, + "request_url" text NOT NULL, + "issued_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "expires_at" timestamp NOT NULL, + "identity_id" uuid NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "active_method" varchar(32), + "state" varchar(255) DEFAULT 'show_form' NOT NULL, + "type" varchar(16) DEFAULT 'browser' NOT NULL, + "ui" jsonb, + "nid" uuid, + "internal_context" jsonb NOT NULL +); +--> statement-breakpoint +CREATE TABLE "continuity_containers" ( + "id" uuid PRIMARY KEY NOT NULL, + "identity_id" uuid, + "name" varchar(255) NOT NULL, + "payload" jsonb, + "expires_at" timestamp NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "nid" uuid +); +--> statement-breakpoint +CREATE TABLE "sessions" ( + "id" uuid PRIMARY KEY NOT NULL, + "issued_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "expires_at" timestamp NOT NULL, + "authenticated_at" timestamp NOT NULL, + "identity_id" uuid NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "token" varchar(39), + "active" boolean DEFAULT false, + "nid" uuid, + "logout_token" varchar(39), + "aal" varchar(4) DEFAULT 'aal1' NOT NULL, + "authentication_methods" jsonb NOT NULL +); +--> statement-breakpoint +CREATE TABLE "identity_recovery_addresses" ( + "id" uuid PRIMARY KEY NOT NULL, + "via" varchar(16) NOT NULL, + "value" varchar(400) NOT NULL, + "identity_id" uuid NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "nid" uuid +); +--> statement-breakpoint +CREATE TABLE "identity_verification_tokens" ( + "id" uuid PRIMARY KEY NOT NULL, + "token" varchar(64) NOT NULL, + "used" boolean DEFAULT false NOT NULL, + "used_at" timestamp, + "expires_at" timestamp NOT NULL, + "issued_at" timestamp NOT NULL, + "identity_verifiable_address_id" uuid NOT NULL, + "selfservice_verification_flow_id" uuid NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "nid" uuid +); +--> statement-breakpoint +CREATE TABLE "selfservice_recovery_flows" ( + "id" uuid PRIMARY KEY NOT NULL, + "request_url" text NOT NULL, + "issued_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "expires_at" timestamp NOT NULL, + "active_method" varchar(32), + "csrf_token" varchar(255) NOT NULL, + "state" varchar(32) NOT NULL, + "recovered_identity_id" uuid, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "type" varchar(16) DEFAULT 'browser' NOT NULL, + "ui" jsonb, + "nid" uuid, + "submit_count" integer DEFAULT 0 NOT NULL, + "skip_csrf_check" boolean DEFAULT false NOT NULL +); +--> statement-breakpoint +CREATE TABLE "identity_recovery_tokens" ( + "id" uuid PRIMARY KEY NOT NULL, + "token" varchar(64) NOT NULL, + "used" boolean DEFAULT false NOT NULL, + "used_at" timestamp, + "identity_recovery_address_id" uuid, + "selfservice_recovery_flow_id" uuid, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "expires_at" timestamp DEFAULT '2000-01-01 00:00:00' NOT NULL, + "issued_at" timestamp DEFAULT '2000-01-01 00:00:00' NOT NULL, + "nid" uuid, + "identity_id" uuid NOT NULL, + "token_type" integer DEFAULT 0 NOT NULL, + CONSTRAINT "identity_recovery_tokens_token_type_ck" CHECK ((token_type = 1) OR (token_type = 2)) +); +--> statement-breakpoint +CREATE TABLE "identity_recovery_codes" ( + "id" uuid PRIMARY KEY NOT NULL, + "code" varchar(64) NOT NULL, + "used_at" timestamp, + "identity_recovery_address_id" uuid, + "code_type" integer NOT NULL, + "expires_at" timestamp DEFAULT '2000-01-01 00:00:00' NOT NULL, + "issued_at" timestamp DEFAULT '2000-01-01 00:00:00' NOT NULL, + "selfservice_recovery_flow_id" uuid NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "nid" uuid NOT NULL, + "identity_id" uuid NOT NULL +); +--> statement-breakpoint +CREATE TABLE "session_devices" ( + "id" uuid PRIMARY KEY NOT NULL, + "ip_address" varchar(50) DEFAULT '', + "user_agent" varchar(512) DEFAULT '', + "location" varchar(512) DEFAULT '', + "nid" uuid NOT NULL, + "session_id" uuid NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + CONSTRAINT "unique_session_device" UNIQUE("ip_address","user_agent","nid","session_id") +); +--> statement-breakpoint +CREATE TABLE "identity_verification_codes" ( + "id" uuid PRIMARY KEY NOT NULL, + "code_hmac" varchar(64) NOT NULL, + "used_at" timestamp, + "identity_verifiable_address_id" uuid, + "expires_at" timestamp DEFAULT '2000-01-01 00:00:00' NOT NULL, + "issued_at" timestamp DEFAULT '2000-01-01 00:00:00' NOT NULL, + "selfservice_verification_flow_id" uuid NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "nid" uuid NOT NULL +); +--> statement-breakpoint +CREATE TABLE "courier_message_dispatches" ( + "id" uuid PRIMARY KEY NOT NULL, + "message_id" uuid NOT NULL, + "status" varchar(7) NOT NULL, + "error" json, + "nid" uuid NOT NULL, + "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "session_token_exchanges" ( + "id" uuid PRIMARY KEY NOT NULL, + "nid" uuid NOT NULL, + "flow_id" uuid NOT NULL, + "session_id" uuid, + "init_code" varchar(64) NOT NULL, + "return_to_code" varchar(64) NOT NULL, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL +); +--> statement-breakpoint +CREATE TABLE "identity_login_codes" ( + "id" uuid PRIMARY KEY NOT NULL, + "code" varchar(64) NOT NULL, + "address" varchar(255) NOT NULL, + "address_type" char(36) NOT NULL, + "used_at" timestamp, + "expires_at" timestamp DEFAULT '2000-01-01 00:00:00' NOT NULL, + "issued_at" timestamp DEFAULT '2000-01-01 00:00:00' NOT NULL, + "selfservice_login_flow_id" uuid NOT NULL, + "identity_id" uuid NOT NULL, + "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "nid" uuid NOT NULL +); +--> statement-breakpoint +CREATE TABLE "identity_registration_codes" ( + "id" uuid PRIMARY KEY NOT NULL, + "code" varchar(64) NOT NULL, + "address" varchar(255) NOT NULL, + "address_type" char(36) NOT NULL, + "used_at" timestamp, + "expires_at" timestamp DEFAULT '2000-01-01 00:00:00' NOT NULL, + "issued_at" timestamp DEFAULT '2000-01-01 00:00:00' NOT NULL, + "selfservice_registration_flow_id" uuid NOT NULL, + "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + "nid" uuid NOT NULL +); +--> statement-breakpoint +ALTER TABLE "identity_credentials" ADD CONSTRAINT "identity_credentials_identity_id_fkey" FOREIGN KEY ("identity_id") REFERENCES "public"."identities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_credentials" ADD CONSTRAINT "identity_credentials_identity_credential_type_id_fkey" FOREIGN KEY ("identity_credential_type_id") REFERENCES "public"."identity_credential_types"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_credentials" ADD CONSTRAINT "identity_credentials_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "selfservice_login_flows" ADD CONSTRAINT "selfservice_login_flows_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "selfservice_registration_flows" ADD CONSTRAINT "selfservice_registration_flows_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identities" ADD CONSTRAINT "identities_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_credential_identifiers" ADD CONSTRAINT "identity_credential_identifiers_identity_credential_id_fkey" FOREIGN KEY ("identity_credential_id") REFERENCES "public"."identity_credentials"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_credential_identifiers" ADD CONSTRAINT "identity_credential_identifiers_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_credential_identifiers" ADD CONSTRAINT "identity_credential_identifiers_type_id_fk_idx" FOREIGN KEY ("identity_credential_type_id") REFERENCES "public"."identity_credential_types"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_verifiable_addresses" ADD CONSTRAINT "identity_verifiable_addresses_identity_id_fkey" FOREIGN KEY ("identity_id") REFERENCES "public"."identities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_verifiable_addresses" ADD CONSTRAINT "identity_verifiable_addresses_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "courier_messages" ADD CONSTRAINT "courier_messages_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "selfservice_errors" ADD CONSTRAINT "selfservice_errors_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "selfservice_verification_flows" ADD CONSTRAINT "selfservice_verification_flows_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "selfservice_settings_flows" ADD CONSTRAINT "selfservice_profile_management_requests_identity_id_fkey" FOREIGN KEY ("identity_id") REFERENCES "public"."identities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "selfservice_settings_flows" ADD CONSTRAINT "selfservice_settings_flows_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "continuity_containers" ADD CONSTRAINT "continuity_containers_identity_id_fkey" FOREIGN KEY ("identity_id") REFERENCES "public"."identities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "continuity_containers" ADD CONSTRAINT "continuity_containers_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "sessions" ADD CONSTRAINT "sessions_identity_id_fkey" FOREIGN KEY ("identity_id") REFERENCES "public"."identities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "sessions" ADD CONSTRAINT "sessions_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_recovery_addresses" ADD CONSTRAINT "identity_recovery_addresses_identity_id_fkey" FOREIGN KEY ("identity_id") REFERENCES "public"."identities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_recovery_addresses" ADD CONSTRAINT "identity_recovery_addresses_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_verification_tokens" ADD CONSTRAINT "identity_verification_tokens_identity_verifiable_address_i_fkey" FOREIGN KEY ("identity_verifiable_address_id") REFERENCES "public"."identity_verifiable_addresses"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_verification_tokens" ADD CONSTRAINT "identity_verification_tokens_selfservice_verification_flow_fkey" FOREIGN KEY ("selfservice_verification_flow_id") REFERENCES "public"."selfservice_verification_flows"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_verification_tokens" ADD CONSTRAINT "identity_verification_tokens_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "selfservice_recovery_flows" ADD CONSTRAINT "selfservice_recovery_requests_recovered_identity_id_fkey" FOREIGN KEY ("recovered_identity_id") REFERENCES "public"."identities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "selfservice_recovery_flows" ADD CONSTRAINT "selfservice_recovery_flows_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_recovery_tokens" ADD CONSTRAINT "identity_recovery_tokens_selfservice_recovery_request_id_fkey" FOREIGN KEY ("selfservice_recovery_flow_id") REFERENCES "public"."selfservice_recovery_flows"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_recovery_tokens" ADD CONSTRAINT "identity_recovery_tokens_nid_fk_idx" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_recovery_tokens" ADD CONSTRAINT "identity_recovery_tokens_identity_recovery_address_id_fkey" FOREIGN KEY ("identity_recovery_address_id") REFERENCES "public"."identity_recovery_addresses"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_recovery_tokens" ADD CONSTRAINT "identity_recovery_tokens_identity_id_fk_idx" FOREIGN KEY ("identity_id") REFERENCES "public"."identities"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_recovery_codes" ADD CONSTRAINT "identity_recovery_codes_identity_recovery_addresses_id_fk" FOREIGN KEY ("identity_recovery_address_id") REFERENCES "public"."identity_recovery_addresses"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_recovery_codes" ADD CONSTRAINT "identity_recovery_codes_selfservice_recovery_flows_id_fk" FOREIGN KEY ("selfservice_recovery_flow_id") REFERENCES "public"."selfservice_recovery_flows"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_recovery_codes" ADD CONSTRAINT "identity_recovery_codes_identity_id_fk" FOREIGN KEY ("identity_id") REFERENCES "public"."identities"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_recovery_codes" ADD CONSTRAINT "identity_recovery_codes_networks_id_fk" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "session_devices" ADD CONSTRAINT "session_metadata_sessions_id_fk" FOREIGN KEY ("session_id") REFERENCES "public"."sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "session_devices" ADD CONSTRAINT "session_metadata_nid_fk" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_verification_codes" ADD CONSTRAINT "identity_verification_codes_identity_verifiable_addresses_id_fk" FOREIGN KEY ("identity_verifiable_address_id") REFERENCES "public"."identity_verifiable_addresses"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_verification_codes" ADD CONSTRAINT "identity_verification_codes_selfservice_verification_flows_id_f" FOREIGN KEY ("selfservice_verification_flow_id") REFERENCES "public"."selfservice_verification_flows"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_verification_codes" ADD CONSTRAINT "identity_verification_codes_networks_id_fk" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "courier_message_dispatches" ADD CONSTRAINT "courier_message_dispatches_message_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."courier_messages"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "courier_message_dispatches" ADD CONSTRAINT "courier_message_dispatches_nid_fk" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_login_codes" ADD CONSTRAINT "identity_login_codes_selfservice_login_flows_id_fk" FOREIGN KEY ("selfservice_login_flow_id") REFERENCES "public"."selfservice_login_flows"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_login_codes" ADD CONSTRAINT "identity_login_codes_networks_id_fk" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_login_codes" ADD CONSTRAINT "identity_login_codes_identity_id_fk" FOREIGN KEY ("identity_id") REFERENCES "public"."identities"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +ALTER TABLE "identity_registration_codes" ADD CONSTRAINT "identity_registration_codes_selfservice_registration_flows_id_f" FOREIGN KEY ("selfservice_registration_flow_id") REFERENCES "public"."selfservice_registration_flows"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "identity_registration_codes" ADD CONSTRAINT "identity_registration_codes_networks_id_fk" FOREIGN KEY ("nid") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE restrict;--> statement-breakpoint +CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" USING btree ("version" text_ops);--> statement-breakpoint +CREATE INDEX "schema_migration_version_self_idx" ON "schema_migration" USING btree ("version_self" int4_ops);--> statement-breakpoint +CREATE INDEX "identity_credentials_id_nid_idx" ON "identity_credentials" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_credentials_nid_id_idx" ON "identity_credentials" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_credentials_nid_identity_id_idx" ON "identity_credentials" USING btree ("identity_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "identity_credential_types_name_idx" ON "identity_credential_types" USING btree ("name" text_ops);--> statement-breakpoint +CREATE INDEX "selfservice_login_flows_id_nid_idx" ON "selfservice_login_flows" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_login_flows_nid_id_idx" ON "selfservice_login_flows" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_registration_flows_id_nid_idx" ON "selfservice_registration_flows" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_registration_flows_nid_id_idx" ON "selfservice_registration_flows" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identities_id_nid_idx" ON "identities" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identities_nid_id_idx" ON "identities" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_credential_identifiers_id_nid_idx" ON "identity_credential_identifiers" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "identity_credential_identifiers_identifier_nid_type_uq_idx" ON "identity_credential_identifiers" USING btree ("nid" uuid_ops,"identity_credential_type_id" uuid_ops,"identifier" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_credential_identifiers_nid_i_ici_idx" ON "identity_credential_identifiers" USING btree ("nid" text_ops,"identifier" text_ops,"identity_credential_id" text_ops);--> statement-breakpoint +CREATE INDEX "identity_credential_identifiers_nid_id_idx" ON "identity_credential_identifiers" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_credential_identifiers_nid_identity_credential_id_idx" ON "identity_credential_identifiers" USING btree ("identity_credential_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verifiable_addresses_id_nid_idx" ON "identity_verifiable_addresses" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verifiable_addresses_nid_id_idx" ON "identity_verifiable_addresses" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verifiable_addresses_nid_identity_id_idx" ON "identity_verifiable_addresses" USING btree ("identity_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verifiable_addresses_status_via_idx" ON "identity_verifiable_addresses" USING btree ("nid" text_ops,"via" text_ops,"value" text_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "identity_verifiable_addresses_status_via_uq_idx" ON "identity_verifiable_addresses" USING btree ("nid" text_ops,"via" text_ops,"value" uuid_ops);--> statement-breakpoint +CREATE INDEX "courier_messages_id_nid_idx" ON "courier_messages" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "courier_messages_nid_created_at_id_idx" ON "courier_messages" USING btree ("nid" timestamp_ops,"created_at" uuid_ops);--> statement-breakpoint +CREATE INDEX "courier_messages_nid_id_idx" ON "courier_messages" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "courier_messages_nid_recipient_created_at_id_idx" ON "courier_messages" USING btree ("nid" timestamp_ops,"recipient" text_ops,"created_at" uuid_ops);--> statement-breakpoint +CREATE INDEX "courier_messages_nid_status_created_at_id_idx" ON "courier_messages" USING btree ("nid" uuid_ops,"status" timestamp_ops,"created_at" uuid_ops);--> statement-breakpoint +CREATE INDEX "courier_messages_status_idx" ON "courier_messages" USING btree ("status" int4_ops);--> statement-breakpoint +CREATE INDEX "selfservice_errors_errors_nid_id_idx" ON "selfservice_errors" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_verification_flows_id_nid_idx" ON "selfservice_verification_flows" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_verification_flows_nid_id_idx" ON "selfservice_verification_flows" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_settings_flows_id_nid_idx" ON "selfservice_settings_flows" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_settings_flows_identity_id_nid_idx" ON "selfservice_settings_flows" USING btree ("identity_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_settings_flows_nid_id_idx" ON "selfservice_settings_flows" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "continuity_containers_id_nid_idx" ON "continuity_containers" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "continuity_containers_identity_id_nid_idx" ON "continuity_containers" USING btree ("identity_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "continuity_containers_nid_id_idx" ON "continuity_containers" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "sessions_id_nid_idx" ON "sessions" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "sessions_identity_id_nid_sorted_idx" ON "sessions" USING btree ("identity_id" timestamp_ops,"nid" timestamp_ops,"authenticated_at" uuid_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "sessions_logout_token_uq_idx" ON "sessions" USING btree ("logout_token" text_ops);--> statement-breakpoint +CREATE INDEX "sessions_nid_created_at_id_idx" ON "sessions" USING btree ("nid" uuid_ops,"created_at" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "sessions_nid_id_identity_id_idx" ON "sessions" USING btree ("nid" uuid_ops,"identity_id" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "sessions_token_nid_idx" ON "sessions" USING btree ("nid" uuid_ops,"token" text_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "sessions_token_uq_idx" ON "sessions" USING btree ("token" text_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_addresses_id_nid_idx" ON "identity_recovery_addresses" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_addresses_nid_id_idx" ON "identity_recovery_addresses" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_addresses_nid_identity_id_idx" ON "identity_recovery_addresses" USING btree ("identity_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_addresses_status_via_idx" ON "identity_recovery_addresses" USING btree ("nid" text_ops,"via" text_ops,"value" text_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "identity_recovery_addresses_status_via_uq_idx" ON "identity_recovery_addresses" USING btree ("nid" text_ops,"via" text_ops,"value" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verification_tokens_id_nid_idx" ON "identity_verification_tokens" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verification_tokens_nid_id_idx" ON "identity_verification_tokens" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verification_tokens_token_nid_used_flow_id_idx" ON "identity_verification_tokens" USING btree ("nid" uuid_ops,"token" bool_ops,"used" text_ops,"selfservice_verification_flow_id" uuid_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "identity_verification_tokens_token_uq_idx" ON "identity_verification_tokens" USING btree ("token" text_ops);--> statement-breakpoint +CREATE INDEX "identity_verification_tokens_verifiable_address_id_idx" ON "identity_verification_tokens" USING btree ("identity_verifiable_address_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verification_tokens_verification_flow_id_idx" ON "identity_verification_tokens" USING btree ("selfservice_verification_flow_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_recovery_flows_id_nid_idx" ON "selfservice_recovery_flows" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_recovery_flows_nid_id_idx" ON "selfservice_recovery_flows" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "selfservice_recovery_flows_recovered_identity_id_nid_idx" ON "selfservice_recovery_flows" USING btree ("recovered_identity_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "identity_recovery_addresses_code_uq_idx" ON "identity_recovery_tokens" USING btree ("token" text_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_tokens_id_nid_idx" ON "identity_recovery_tokens" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_tokens_identity_id_nid_idx" ON "identity_recovery_tokens" USING btree ("identity_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_tokens_identity_recovery_address_id_idx" ON "identity_recovery_tokens" USING btree ("identity_recovery_address_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_tokens_nid_id_idx" ON "identity_recovery_tokens" USING btree ("nid" uuid_ops,"id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_tokens_selfservice_recovery_flow_id_idx" ON "identity_recovery_tokens" USING btree ("selfservice_recovery_flow_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_tokens_token_nid_used_idx" ON "identity_recovery_tokens" USING btree ("nid" bool_ops,"token" text_ops,"used" bool_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_codes_flow_id_idx" ON "identity_recovery_codes" USING btree ("selfservice_recovery_flow_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_codes_id_nid_idx" ON "identity_recovery_codes" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_codes_identity_id_nid_idx" ON "identity_recovery_codes" USING btree ("identity_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_codes_identity_recovery_address_id_nid_idx" ON "identity_recovery_codes" USING btree ("identity_recovery_address_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_recovery_codes_nid_flow_id_idx" ON "identity_recovery_codes" USING btree ("nid" uuid_ops,"selfservice_recovery_flow_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "session_devices_id_nid_idx" ON "session_devices" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "session_devices_session_id_nid_idx" ON "session_devices" USING btree ("session_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verification_codes_flow_id_idx" ON "identity_verification_codes" USING btree ("selfservice_verification_flow_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verification_codes_id_nid_idx" ON "identity_verification_codes" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verification_codes_nid_flow_id_idx" ON "identity_verification_codes" USING btree ("nid" uuid_ops,"selfservice_verification_flow_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_verification_codes_verifiable_address_nid_idx" ON "identity_verification_codes" USING btree ("identity_verifiable_address_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "courier_message_dispatches_message_id_idx" ON "courier_message_dispatches" USING btree ("message_id" timestamp_ops,"created_at" timestamp_ops);--> statement-breakpoint +CREATE INDEX "courier_message_dispatches_nid_idx" ON "courier_message_dispatches" USING btree ("nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "session_token_exchanges_nid_code_idx" ON "session_token_exchanges" USING btree ("init_code" uuid_ops,"nid" text_ops);--> statement-breakpoint +CREATE INDEX "session_token_exchanges_nid_flow_id_idx" ON "session_token_exchanges" USING btree ("flow_id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_login_codes_flow_id_idx" ON "identity_login_codes" USING btree ("selfservice_login_flow_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_login_codes_id_nid_idx" ON "identity_login_codes" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_login_codes_identity_id_idx" ON "identity_login_codes" USING btree ("identity_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_login_codes_nid_flow_id_idx" ON "identity_login_codes" USING btree ("nid" uuid_ops,"selfservice_login_flow_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_registration_codes_flow_id_idx" ON "identity_registration_codes" USING btree ("selfservice_registration_flow_id" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_registration_codes_id_nid_idx" ON "identity_registration_codes" USING btree ("id" uuid_ops,"nid" uuid_ops);--> statement-breakpoint +CREATE INDEX "identity_registration_codes_nid_flow_id_idx" ON "identity_registration_codes" USING btree ("nid" uuid_ops,"selfservice_registration_flow_id" uuid_ops); +*/ \ No newline at end of file diff --git a/dashboard/drizzle/meta/0000_snapshot.json b/dashboard/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..4d455bc --- /dev/null +++ b/dashboard/drizzle/meta/0000_snapshot.json @@ -0,0 +1,4700 @@ +{ + "id": "00000000-0000-0000-0000-000000000000", + "prevId": "", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.schema_migration": { + "name": "schema_migration", + "schema": "", + "columns": { + "version": { + "name": "version", + "type": "varchar(48)", + "primaryKey": false, + "notNull": true + }, + "version_self": { + "name": "version_self", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "schema_migration_version_idx": { + "name": "schema_migration_version_idx", + "columns": [ + { + "expression": "version", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "schema_migration_version_self_idx": { + "name": "schema_migration_version_self_idx", + "columns": [ + { + "expression": "version_self", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_credentials": { + "name": "identity_credentials", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "identity_credential_type_id": { + "name": "identity_credential_type_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "identity_id": { + "name": "identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "identity_credentials_id_nid_idx": { + "name": "identity_credentials_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_credentials_nid_id_idx": { + "name": "identity_credentials_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_credentials_nid_identity_id_idx": { + "name": "identity_credentials_nid_identity_id_idx", + "columns": [ + { + "expression": "identity_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identity_credentials_identity_id_fkey": { + "name": "identity_credentials_identity_id_fkey", + "tableFrom": "identity_credentials", + "tableTo": "identities", + "schemaTo": "public", + "columnsFrom": [ + "identity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_credentials_identity_credential_type_id_fkey": { + "name": "identity_credentials_identity_credential_type_id_fkey", + "tableFrom": "identity_credentials", + "tableTo": "identity_credential_types", + "schemaTo": "public", + "columnsFrom": [ + "identity_credential_type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_credentials_nid_fk_idx": { + "name": "identity_credentials_nid_fk_idx", + "tableFrom": "identity_credentials", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_credential_types": { + "name": "identity_credential_types", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "identity_credential_types_name_idx": { + "name": "identity_credential_types_name_idx", + "columns": [ + { + "expression": "name", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.selfservice_login_flows": { + "name": "selfservice_login_flows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "request_url": { + "name": "request_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "active_method": { + "name": "active_method", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "csrf_token": { + "name": "csrf_token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "forced": { + "name": "forced", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "type": { + "name": "type", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true, + "default": "'browser'" + }, + "ui": { + "name": "ui", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "requested_aal": { + "name": "requested_aal", + "type": "varchar(4)", + "primaryKey": false, + "notNull": true, + "default": "'aal1'" + }, + "internal_context": { + "name": "internal_context", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "oauth2_login_challenge": { + "name": "oauth2_login_challenge", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "oauth2_login_challenge_data": { + "name": "oauth2_login_challenge_data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "submit_count": { + "name": "submit_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "selfservice_login_flows_id_nid_idx": { + "name": "selfservice_login_flows_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "selfservice_login_flows_nid_id_idx": { + "name": "selfservice_login_flows_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "selfservice_login_flows_nid_fk_idx": { + "name": "selfservice_login_flows_nid_fk_idx", + "tableFrom": "selfservice_login_flows", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.networks": { + "name": "networks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.selfservice_registration_flows": { + "name": "selfservice_registration_flows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "request_url": { + "name": "request_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "active_method": { + "name": "active_method", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "csrf_token": { + "name": "csrf_token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true, + "default": "'browser'" + }, + "ui": { + "name": "ui", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "internal_context": { + "name": "internal_context", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "oauth2_login_challenge": { + "name": "oauth2_login_challenge", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "oauth2_login_challenge_data": { + "name": "oauth2_login_challenge_data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "submit_count": { + "name": "submit_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "selfservice_registration_flows_id_nid_idx": { + "name": "selfservice_registration_flows_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "selfservice_registration_flows_nid_id_idx": { + "name": "selfservice_registration_flows_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "selfservice_registration_flows_nid_fk_idx": { + "name": "selfservice_registration_flows_nid_fk_idx", + "tableFrom": "selfservice_registration_flows", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identities": { + "name": "identities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "schema_id": { + "name": "schema_id", + "type": "varchar(2048)", + "primaryKey": false, + "notNull": true + }, + "traits": { + "name": "traits", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "state_changed_at": { + "name": "state_changed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "metadata_public": { + "name": "metadata_public", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "metadata_admin": { + "name": "metadata_admin", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "available_aal": { + "name": "available_aal", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "identities_id_nid_idx": { + "name": "identities_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identities_nid_id_idx": { + "name": "identities_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identities_nid_fk_idx": { + "name": "identities_nid_fk_idx", + "tableFrom": "identities", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_credential_identifiers": { + "name": "identity_credential_identifiers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "identity_credential_id": { + "name": "identity_credential_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "identity_credential_type_id": { + "name": "identity_credential_type_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "identity_credential_identifiers_id_nid_idx": { + "name": "identity_credential_identifiers_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_credential_identifiers_identifier_nid_type_uq_idx": { + "name": "identity_credential_identifiers_identifier_nid_type_uq_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "identity_credential_type_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "identifier", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_credential_identifiers_nid_i_ici_idx": { + "name": "identity_credential_identifiers_nid_i_ici_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "identifier", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "identity_credential_id", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_credential_identifiers_nid_id_idx": { + "name": "identity_credential_identifiers_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_credential_identifiers_nid_identity_credential_id_idx": { + "name": "identity_credential_identifiers_nid_identity_credential_id_idx", + "columns": [ + { + "expression": "identity_credential_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identity_credential_identifiers_identity_credential_id_fkey": { + "name": "identity_credential_identifiers_identity_credential_id_fkey", + "tableFrom": "identity_credential_identifiers", + "tableTo": "identity_credentials", + "schemaTo": "public", + "columnsFrom": [ + "identity_credential_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_credential_identifiers_nid_fk_idx": { + "name": "identity_credential_identifiers_nid_fk_idx", + "tableFrom": "identity_credential_identifiers", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + }, + "identity_credential_identifiers_type_id_fk_idx": { + "name": "identity_credential_identifiers_type_id_fk_idx", + "tableFrom": "identity_credential_identifiers", + "tableTo": "identity_credential_types", + "schemaTo": "public", + "columnsFrom": [ + "identity_credential_type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_verifiable_addresses": { + "name": "identity_verifiable_addresses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "via": { + "name": "via", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "varchar(400)", + "primaryKey": false, + "notNull": true + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "identity_id": { + "name": "identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "identity_verifiable_addresses_id_nid_idx": { + "name": "identity_verifiable_addresses_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verifiable_addresses_nid_id_idx": { + "name": "identity_verifiable_addresses_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verifiable_addresses_nid_identity_id_idx": { + "name": "identity_verifiable_addresses_nid_identity_id_idx", + "columns": [ + { + "expression": "identity_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verifiable_addresses_status_via_idx": { + "name": "identity_verifiable_addresses_status_via_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "via", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "value", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verifiable_addresses_status_via_uq_idx": { + "name": "identity_verifiable_addresses_status_via_uq_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "via", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "value", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identity_verifiable_addresses_identity_id_fkey": { + "name": "identity_verifiable_addresses_identity_id_fkey", + "tableFrom": "identity_verifiable_addresses", + "tableTo": "identities", + "schemaTo": "public", + "columnsFrom": [ + "identity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_verifiable_addresses_nid_fk_idx": { + "name": "identity_verifiable_addresses_nid_fk_idx", + "tableFrom": "identity_verifiable_addresses", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.courier_messages": { + "name": "courier_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "recipient": { + "name": "recipient", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "template_type": { + "name": "template_type", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "template_data": { + "name": "template_data", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "send_count": { + "name": "send_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "channel": { + "name": "channel", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "courier_messages_id_nid_idx": { + "name": "courier_messages_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "courier_messages_nid_created_at_id_idx": { + "name": "courier_messages_nid_created_at_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "timestamp_ops", + "isExpression": false + }, + { + "expression": "created_at", + "asc": false, + "nulls": "first", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "courier_messages_nid_id_idx": { + "name": "courier_messages_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "courier_messages_nid_recipient_created_at_id_idx": { + "name": "courier_messages_nid_recipient_created_at_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "timestamp_ops", + "isExpression": false + }, + { + "expression": "recipient", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "created_at", + "asc": false, + "nulls": "first", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "courier_messages_nid_status_created_at_id_idx": { + "name": "courier_messages_nid_status_created_at_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "status", + "asc": true, + "nulls": "last", + "opclass": "timestamp_ops", + "isExpression": false + }, + { + "expression": "created_at", + "asc": false, + "nulls": "first", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "courier_messages_status_idx": { + "name": "courier_messages_status_idx", + "columns": [ + { + "expression": "status", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "courier_messages_nid_fk_idx": { + "name": "courier_messages_nid_fk_idx", + "tableFrom": "courier_messages", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.selfservice_errors": { + "name": "selfservice_errors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "errors": { + "name": "errors", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "seen_at": { + "name": "seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "was_seen": { + "name": "was_seen", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "csrf_token": { + "name": "csrf_token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "selfservice_errors_errors_nid_id_idx": { + "name": "selfservice_errors_errors_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "selfservice_errors_nid_fk_idx": { + "name": "selfservice_errors_nid_fk_idx", + "tableFrom": "selfservice_errors", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.selfservice_verification_flows": { + "name": "selfservice_verification_flows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "request_url": { + "name": "request_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "csrf_token": { + "name": "csrf_token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true, + "default": "'browser'" + }, + "state": { + "name": "state", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "default": "'show_form'" + }, + "active_method": { + "name": "active_method", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false + }, + "ui": { + "name": "ui", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "submit_count": { + "name": "submit_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "oauth2_login_challenge": { + "name": "oauth2_login_challenge", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "identity_id": { + "name": "identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "authentication_methods": { + "name": "authentication_methods", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "selfservice_verification_flows_id_nid_idx": { + "name": "selfservice_verification_flows_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "selfservice_verification_flows_nid_id_idx": { + "name": "selfservice_verification_flows_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "selfservice_verification_flows_nid_fk_idx": { + "name": "selfservice_verification_flows_nid_fk_idx", + "tableFrom": "selfservice_verification_flows", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.selfservice_settings_flows": { + "name": "selfservice_settings_flows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "request_url": { + "name": "request_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "identity_id": { + "name": "identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "active_method": { + "name": "active_method", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "default": "'show_form'" + }, + "type": { + "name": "type", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true, + "default": "'browser'" + }, + "ui": { + "name": "ui", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "internal_context": { + "name": "internal_context", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "selfservice_settings_flows_id_nid_idx": { + "name": "selfservice_settings_flows_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "selfservice_settings_flows_identity_id_nid_idx": { + "name": "selfservice_settings_flows_identity_id_nid_idx", + "columns": [ + { + "expression": "identity_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "selfservice_settings_flows_nid_id_idx": { + "name": "selfservice_settings_flows_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "selfservice_profile_management_requests_identity_id_fkey": { + "name": "selfservice_profile_management_requests_identity_id_fkey", + "tableFrom": "selfservice_settings_flows", + "tableTo": "identities", + "schemaTo": "public", + "columnsFrom": [ + "identity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "selfservice_settings_flows_nid_fk_idx": { + "name": "selfservice_settings_flows_nid_fk_idx", + "tableFrom": "selfservice_settings_flows", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.continuity_containers": { + "name": "continuity_containers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "identity_id": { + "name": "identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "continuity_containers_id_nid_idx": { + "name": "continuity_containers_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "continuity_containers_identity_id_nid_idx": { + "name": "continuity_containers_identity_id_nid_idx", + "columns": [ + { + "expression": "identity_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "continuity_containers_nid_id_idx": { + "name": "continuity_containers_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "continuity_containers_identity_id_fkey": { + "name": "continuity_containers_identity_id_fkey", + "tableFrom": "continuity_containers", + "tableTo": "identities", + "schemaTo": "public", + "columnsFrom": [ + "identity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "continuity_containers_nid_fk_idx": { + "name": "continuity_containers_nid_fk_idx", + "tableFrom": "continuity_containers", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "authenticated_at": { + "name": "authenticated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "identity_id": { + "name": "identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(39)", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "logout_token": { + "name": "logout_token", + "type": "varchar(39)", + "primaryKey": false, + "notNull": false + }, + "aal": { + "name": "aal", + "type": "varchar(4)", + "primaryKey": false, + "notNull": true, + "default": "'aal1'" + }, + "authentication_methods": { + "name": "authentication_methods", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "sessions_id_nid_idx": { + "name": "sessions_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sessions_identity_id_nid_sorted_idx": { + "name": "sessions_identity_id_nid_sorted_idx", + "columns": [ + { + "expression": "identity_id", + "asc": true, + "nulls": "last", + "opclass": "timestamp_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "timestamp_ops", + "isExpression": false + }, + { + "expression": "authenticated_at", + "asc": false, + "nulls": "first", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sessions_logout_token_uq_idx": { + "name": "sessions_logout_token_uq_idx", + "columns": [ + { + "expression": "logout_token", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sessions_nid_created_at_id_idx": { + "name": "sessions_nid_created_at_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "created_at", + "asc": false, + "nulls": "first", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sessions_nid_id_identity_id_idx": { + "name": "sessions_nid_id_identity_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "identity_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sessions_token_nid_idx": { + "name": "sessions_token_nid_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "token", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sessions_token_uq_idx": { + "name": "sessions_token_uq_idx", + "columns": [ + { + "expression": "token", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_identity_id_fkey": { + "name": "sessions_identity_id_fkey", + "tableFrom": "sessions", + "tableTo": "identities", + "schemaTo": "public", + "columnsFrom": [ + "identity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sessions_nid_fk_idx": { + "name": "sessions_nid_fk_idx", + "tableFrom": "sessions", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_recovery_addresses": { + "name": "identity_recovery_addresses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "via": { + "name": "via", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "varchar(400)", + "primaryKey": false, + "notNull": true + }, + "identity_id": { + "name": "identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "identity_recovery_addresses_id_nid_idx": { + "name": "identity_recovery_addresses_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_addresses_nid_id_idx": { + "name": "identity_recovery_addresses_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_addresses_nid_identity_id_idx": { + "name": "identity_recovery_addresses_nid_identity_id_idx", + "columns": [ + { + "expression": "identity_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_addresses_status_via_idx": { + "name": "identity_recovery_addresses_status_via_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "via", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "value", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_addresses_status_via_uq_idx": { + "name": "identity_recovery_addresses_status_via_uq_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "via", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "value", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identity_recovery_addresses_identity_id_fkey": { + "name": "identity_recovery_addresses_identity_id_fkey", + "tableFrom": "identity_recovery_addresses", + "tableTo": "identities", + "schemaTo": "public", + "columnsFrom": [ + "identity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_recovery_addresses_nid_fk_idx": { + "name": "identity_recovery_addresses_nid_fk_idx", + "tableFrom": "identity_recovery_addresses", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_verification_tokens": { + "name": "identity_verification_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "used": { + "name": "used", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "identity_verifiable_address_id": { + "name": "identity_verifiable_address_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "selfservice_verification_flow_id": { + "name": "selfservice_verification_flow_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "identity_verification_tokens_id_nid_idx": { + "name": "identity_verification_tokens_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verification_tokens_nid_id_idx": { + "name": "identity_verification_tokens_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verification_tokens_token_nid_used_flow_id_idx": { + "name": "identity_verification_tokens_token_nid_used_flow_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "token", + "asc": true, + "nulls": "last", + "opclass": "bool_ops", + "isExpression": false + }, + { + "expression": "used", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "selfservice_verification_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verification_tokens_token_uq_idx": { + "name": "identity_verification_tokens_token_uq_idx", + "columns": [ + { + "expression": "token", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verification_tokens_verifiable_address_id_idx": { + "name": "identity_verification_tokens_verifiable_address_id_idx", + "columns": [ + { + "expression": "identity_verifiable_address_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verification_tokens_verification_flow_id_idx": { + "name": "identity_verification_tokens_verification_flow_id_idx", + "columns": [ + { + "expression": "selfservice_verification_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identity_verification_tokens_identity_verifiable_address_i_fkey": { + "name": "identity_verification_tokens_identity_verifiable_address_i_fkey", + "tableFrom": "identity_verification_tokens", + "tableTo": "identity_verifiable_addresses", + "schemaTo": "public", + "columnsFrom": [ + "identity_verifiable_address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_verification_tokens_selfservice_verification_flow_fkey": { + "name": "identity_verification_tokens_selfservice_verification_flow_fkey", + "tableFrom": "identity_verification_tokens", + "tableTo": "selfservice_verification_flows", + "schemaTo": "public", + "columnsFrom": [ + "selfservice_verification_flow_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_verification_tokens_nid_fk_idx": { + "name": "identity_verification_tokens_nid_fk_idx", + "tableFrom": "identity_verification_tokens", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.selfservice_recovery_flows": { + "name": "selfservice_recovery_flows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "request_url": { + "name": "request_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "active_method": { + "name": "active_method", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false + }, + "csrf_token": { + "name": "csrf_token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "recovered_identity_id": { + "name": "recovered_identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true, + "default": "'browser'" + }, + "ui": { + "name": "ui", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "submit_count": { + "name": "submit_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skip_csrf_check": { + "name": "skip_csrf_check", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "selfservice_recovery_flows_id_nid_idx": { + "name": "selfservice_recovery_flows_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "selfservice_recovery_flows_nid_id_idx": { + "name": "selfservice_recovery_flows_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "selfservice_recovery_flows_recovered_identity_id_nid_idx": { + "name": "selfservice_recovery_flows_recovered_identity_id_nid_idx", + "columns": [ + { + "expression": "recovered_identity_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "selfservice_recovery_requests_recovered_identity_id_fkey": { + "name": "selfservice_recovery_requests_recovered_identity_id_fkey", + "tableFrom": "selfservice_recovery_flows", + "tableTo": "identities", + "schemaTo": "public", + "columnsFrom": [ + "recovered_identity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "selfservice_recovery_flows_nid_fk_idx": { + "name": "selfservice_recovery_flows_nid_fk_idx", + "tableFrom": "selfservice_recovery_flows", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_recovery_tokens": { + "name": "identity_recovery_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "used": { + "name": "used", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "identity_recovery_address_id": { + "name": "identity_recovery_address_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "selfservice_recovery_flow_id": { + "name": "selfservice_recovery_flow_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "'2000-01-01 00:00:00'" + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "'2000-01-01 00:00:00'" + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "identity_id": { + "name": "identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_type": { + "name": "token_type", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "identity_recovery_addresses_code_uq_idx": { + "name": "identity_recovery_addresses_code_uq_idx", + "columns": [ + { + "expression": "token", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_tokens_id_nid_idx": { + "name": "identity_recovery_tokens_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_tokens_identity_id_nid_idx": { + "name": "identity_recovery_tokens_identity_id_nid_idx", + "columns": [ + { + "expression": "identity_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_tokens_identity_recovery_address_id_idx": { + "name": "identity_recovery_tokens_identity_recovery_address_id_idx", + "columns": [ + { + "expression": "identity_recovery_address_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_tokens_nid_id_idx": { + "name": "identity_recovery_tokens_nid_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_tokens_selfservice_recovery_flow_id_idx": { + "name": "identity_recovery_tokens_selfservice_recovery_flow_id_idx", + "columns": [ + { + "expression": "selfservice_recovery_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_tokens_token_nid_used_idx": { + "name": "identity_recovery_tokens_token_nid_used_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "bool_ops", + "isExpression": false + }, + { + "expression": "token", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "used", + "asc": true, + "nulls": "last", + "opclass": "bool_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identity_recovery_tokens_selfservice_recovery_request_id_fkey": { + "name": "identity_recovery_tokens_selfservice_recovery_request_id_fkey", + "tableFrom": "identity_recovery_tokens", + "tableTo": "selfservice_recovery_flows", + "schemaTo": "public", + "columnsFrom": [ + "selfservice_recovery_flow_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_recovery_tokens_nid_fk_idx": { + "name": "identity_recovery_tokens_nid_fk_idx", + "tableFrom": "identity_recovery_tokens", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + }, + "identity_recovery_tokens_identity_recovery_address_id_fkey": { + "name": "identity_recovery_tokens_identity_recovery_address_id_fkey", + "tableFrom": "identity_recovery_tokens", + "tableTo": "identity_recovery_addresses", + "schemaTo": "public", + "columnsFrom": [ + "identity_recovery_address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_recovery_tokens_identity_id_fk_idx": { + "name": "identity_recovery_tokens_identity_id_fk_idx", + "tableFrom": "identity_recovery_tokens", + "tableTo": "identities", + "schemaTo": "public", + "columnsFrom": [ + "identity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "identity_recovery_tokens_token_type_ck": { + "name": "identity_recovery_tokens_token_type_ck", + "value": "(token_type = 1) OR (token_type = 2)" + } + }, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_recovery_codes": { + "name": "identity_recovery_codes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "code": { + "name": "code", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "identity_recovery_address_id": { + "name": "identity_recovery_address_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "code_type": { + "name": "code_type", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "'2000-01-01 00:00:00'" + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "'2000-01-01 00:00:00'" + }, + "selfservice_recovery_flow_id": { + "name": "selfservice_recovery_flow_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "identity_id": { + "name": "identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "identity_recovery_codes_flow_id_idx": { + "name": "identity_recovery_codes_flow_id_idx", + "columns": [ + { + "expression": "selfservice_recovery_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_codes_id_nid_idx": { + "name": "identity_recovery_codes_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_codes_identity_id_nid_idx": { + "name": "identity_recovery_codes_identity_id_nid_idx", + "columns": [ + { + "expression": "identity_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_codes_identity_recovery_address_id_nid_idx": { + "name": "identity_recovery_codes_identity_recovery_address_id_nid_idx", + "columns": [ + { + "expression": "identity_recovery_address_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_recovery_codes_nid_flow_id_idx": { + "name": "identity_recovery_codes_nid_flow_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "selfservice_recovery_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identity_recovery_codes_identity_recovery_addresses_id_fk": { + "name": "identity_recovery_codes_identity_recovery_addresses_id_fk", + "tableFrom": "identity_recovery_codes", + "tableTo": "identity_recovery_addresses", + "schemaTo": "public", + "columnsFrom": [ + "identity_recovery_address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_recovery_codes_selfservice_recovery_flows_id_fk": { + "name": "identity_recovery_codes_selfservice_recovery_flows_id_fk", + "tableFrom": "identity_recovery_codes", + "tableTo": "selfservice_recovery_flows", + "schemaTo": "public", + "columnsFrom": [ + "selfservice_recovery_flow_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_recovery_codes_identity_id_fk": { + "name": "identity_recovery_codes_identity_id_fk", + "tableFrom": "identity_recovery_codes", + "tableTo": "identities", + "schemaTo": "public", + "columnsFrom": [ + "identity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + }, + "identity_recovery_codes_networks_id_fk": { + "name": "identity_recovery_codes_networks_id_fk", + "tableFrom": "identity_recovery_codes", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.session_devices": { + "name": "session_devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "user_agent": { + "name": "user_agent", + "type": "varchar(512)", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "location": { + "name": "location", + "type": "varchar(512)", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "session_devices_id_nid_idx": { + "name": "session_devices_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "session_devices_session_id_nid_idx": { + "name": "session_devices_session_id_nid_idx", + "columns": [ + { + "expression": "session_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_metadata_sessions_id_fk": { + "name": "session_metadata_sessions_id_fk", + "tableFrom": "session_devices", + "tableTo": "sessions", + "schemaTo": "public", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "session_metadata_nid_fk": { + "name": "session_metadata_nid_fk", + "tableFrom": "session_devices", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_session_device": { + "columns": [ + "ip_address", + "user_agent", + "nid", + "session_id" + ], + "nullsNotDistinct": false, + "name": "unique_session_device" + } + }, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_verification_codes": { + "name": "identity_verification_codes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "code_hmac": { + "name": "code_hmac", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "identity_verifiable_address_id": { + "name": "identity_verifiable_address_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "'2000-01-01 00:00:00'" + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "'2000-01-01 00:00:00'" + }, + "selfservice_verification_flow_id": { + "name": "selfservice_verification_flow_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "identity_verification_codes_flow_id_idx": { + "name": "identity_verification_codes_flow_id_idx", + "columns": [ + { + "expression": "selfservice_verification_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verification_codes_id_nid_idx": { + "name": "identity_verification_codes_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verification_codes_nid_flow_id_idx": { + "name": "identity_verification_codes_nid_flow_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "selfservice_verification_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_verification_codes_verifiable_address_nid_idx": { + "name": "identity_verification_codes_verifiable_address_nid_idx", + "columns": [ + { + "expression": "identity_verifiable_address_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identity_verification_codes_identity_verifiable_addresses_id_fk": { + "name": "identity_verification_codes_identity_verifiable_addresses_id_fk", + "tableFrom": "identity_verification_codes", + "tableTo": "identity_verifiable_addresses", + "schemaTo": "public", + "columnsFrom": [ + "identity_verifiable_address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_verification_codes_selfservice_verification_flows_id_f": { + "name": "identity_verification_codes_selfservice_verification_flows_id_f", + "tableFrom": "identity_verification_codes", + "tableTo": "selfservice_verification_flows", + "schemaTo": "public", + "columnsFrom": [ + "selfservice_verification_flow_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_verification_codes_networks_id_fk": { + "name": "identity_verification_codes_networks_id_fk", + "tableFrom": "identity_verification_codes", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.courier_message_dispatches": { + "name": "courier_message_dispatches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar(7)", + "primaryKey": false, + "notNull": true + }, + "error": { + "name": "error", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "courier_message_dispatches_message_id_idx": { + "name": "courier_message_dispatches_message_id_idx", + "columns": [ + { + "expression": "message_id", + "asc": true, + "nulls": "last", + "opclass": "timestamp_ops", + "isExpression": false + }, + { + "expression": "created_at", + "asc": false, + "nulls": "first", + "opclass": "timestamp_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "courier_message_dispatches_nid_idx": { + "name": "courier_message_dispatches_nid_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "courier_message_dispatches_message_id_fk": { + "name": "courier_message_dispatches_message_id_fk", + "tableFrom": "courier_message_dispatches", + "tableTo": "courier_messages", + "schemaTo": "public", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "courier_message_dispatches_nid_fk": { + "name": "courier_message_dispatches_nid_fk", + "tableFrom": "courier_message_dispatches", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.session_token_exchanges": { + "name": "session_token_exchanges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "flow_id": { + "name": "flow_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "init_code": { + "name": "init_code", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "return_to_code": { + "name": "return_to_code", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "session_token_exchanges_nid_code_idx": { + "name": "session_token_exchanges_nid_code_idx", + "columns": [ + { + "expression": "init_code", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "session_token_exchanges_nid_flow_id_idx": { + "name": "session_token_exchanges_nid_flow_id_idx", + "columns": [ + { + "expression": "flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_login_codes": { + "name": "identity_login_codes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "code": { + "name": "code", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_type": { + "name": "address_type", + "type": "char(36)", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "'2000-01-01 00:00:00'" + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "'2000-01-01 00:00:00'" + }, + "selfservice_login_flow_id": { + "name": "selfservice_login_flow_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "identity_id": { + "name": "identity_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "identity_login_codes_flow_id_idx": { + "name": "identity_login_codes_flow_id_idx", + "columns": [ + { + "expression": "selfservice_login_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_login_codes_id_nid_idx": { + "name": "identity_login_codes_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_login_codes_identity_id_idx": { + "name": "identity_login_codes_identity_id_idx", + "columns": [ + { + "expression": "identity_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_login_codes_nid_flow_id_idx": { + "name": "identity_login_codes_nid_flow_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "selfservice_login_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identity_login_codes_selfservice_login_flows_id_fk": { + "name": "identity_login_codes_selfservice_login_flows_id_fk", + "tableFrom": "identity_login_codes", + "tableTo": "selfservice_login_flows", + "schemaTo": "public", + "columnsFrom": [ + "selfservice_login_flow_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_login_codes_networks_id_fk": { + "name": "identity_login_codes_networks_id_fk", + "tableFrom": "identity_login_codes", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + }, + "identity_login_codes_identity_id_fk": { + "name": "identity_login_codes_identity_id_fk", + "tableFrom": "identity_login_codes", + "tableTo": "identities", + "schemaTo": "public", + "columnsFrom": [ + "identity_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.identity_registration_codes": { + "name": "identity_registration_codes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "code": { + "name": "code", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_type": { + "name": "address_type", + "type": "char(36)", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "'2000-01-01 00:00:00'" + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "'2000-01-01 00:00:00'" + }, + "selfservice_registration_flow_id": { + "name": "selfservice_registration_flow_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "nid": { + "name": "nid", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "identity_registration_codes_flow_id_idx": { + "name": "identity_registration_codes_flow_id_idx", + "columns": [ + { + "expression": "selfservice_registration_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_registration_codes_id_nid_idx": { + "name": "identity_registration_codes_id_nid_idx", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "identity_registration_codes_nid_flow_id_idx": { + "name": "identity_registration_codes_nid_flow_id_idx", + "columns": [ + { + "expression": "nid", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + }, + { + "expression": "selfservice_registration_flow_id", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "identity_registration_codes_selfservice_registration_flows_id_f": { + "name": "identity_registration_codes_selfservice_registration_flows_id_f", + "tableFrom": "identity_registration_codes", + "tableTo": "selfservice_registration_flows", + "schemaTo": "public", + "columnsFrom": [ + "selfservice_registration_flow_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "identity_registration_codes_networks_id_fk": { + "name": "identity_registration_codes_networks_id_fk", + "tableFrom": "identity_registration_codes", + "tableTo": "networks", + "schemaTo": "public", + "columnsFrom": [ + "nid" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {} + } +} \ No newline at end of file diff --git a/dashboard/drizzle/meta/_journal.json b/dashboard/drizzle/meta/_journal.json new file mode 100644 index 0000000..b7874f0 --- /dev/null +++ b/dashboard/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1735943555589, + "tag": "0000_square_moondragon", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/dashboard/drizzle/relations.ts b/dashboard/drizzle/relations.ts index e69de29..615b353 100644 --- a/dashboard/drizzle/relations.ts +++ b/dashboard/drizzle/relations.ts @@ -0,0 +1,334 @@ +import { relations } from 'drizzle-orm/relations'; +import { + continuityContainers, + courierMessageDispatches, + courierMessages, + identities, + identityCredentialIdentifiers, + identityCredentials, + identityCredentialTypes, + identityLoginCodes, + identityRecoveryAddresses, + identityRecoveryCodes, + identityRecoveryTokens, + identityRegistrationCodes, + identityVerifiableAddresses, + identityVerificationCodes, + identityVerificationTokens, + networks, + selfserviceErrors, + selfserviceLoginFlows, + selfserviceRecoveryFlows, + selfserviceRegistrationFlows, + selfserviceSettingsFlows, + selfserviceVerificationFlows, + sessionDevices, + sessions, +} from './schema'; + +export const identityCredentialsRelations = relations(identityCredentials, ({ one, many }) => ({ + identity: one(identities, { + fields: [identityCredentials.identityId], + references: [identities.id], + }), + identityCredentialType: one(identityCredentialTypes, { + fields: [identityCredentials.identityCredentialTypeId], + references: [identityCredentialTypes.id], + }), + network: one(networks, { + fields: [identityCredentials.nid], + references: [networks.id], + }), + identityCredentialIdentifiers: many(identityCredentialIdentifiers), +})); + +export const identitiesRelations = relations(identities, ({ one, many }) => ({ + identityCredentials: many(identityCredentials), + network: one(networks, { + fields: [identities.nid], + references: [networks.id], + }), + identityVerifiableAddresses: many(identityVerifiableAddresses), + selfserviceSettingsFlows: many(selfserviceSettingsFlows), + continuityContainers: many(continuityContainers), + sessions: many(sessions), + identityRecoveryAddresses: many(identityRecoveryAddresses), + selfserviceRecoveryFlows: many(selfserviceRecoveryFlows), + identityRecoveryTokens: many(identityRecoveryTokens), + identityRecoveryCodes: many(identityRecoveryCodes), + identityLoginCodes: many(identityLoginCodes), +})); + +export const identityCredentialTypesRelations = relations(identityCredentialTypes, ({ many }) => ({ + identityCredentials: many(identityCredentials), + identityCredentialIdentifiers: many(identityCredentialIdentifiers), +})); + +export const networksRelations = relations(networks, ({ many }) => ({ + identityCredentials: many(identityCredentials), + selfserviceLoginFlows: many(selfserviceLoginFlows), + selfserviceRegistrationFlows: many(selfserviceRegistrationFlows), + identities: many(identities), + identityCredentialIdentifiers: many(identityCredentialIdentifiers), + identityVerifiableAddresses: many(identityVerifiableAddresses), + courierMessages: many(courierMessages), + selfserviceErrors: many(selfserviceErrors), + selfserviceVerificationFlows: many(selfserviceVerificationFlows), + selfserviceSettingsFlows: many(selfserviceSettingsFlows), + continuityContainers: many(continuityContainers), + sessions: many(sessions), + identityRecoveryAddresses: many(identityRecoveryAddresses), + identityVerificationTokens: many(identityVerificationTokens), + selfserviceRecoveryFlows: many(selfserviceRecoveryFlows), + identityRecoveryTokens: many(identityRecoveryTokens), + identityRecoveryCodes: many(identityRecoveryCodes), + sessionDevices: many(sessionDevices), + identityVerificationCodes: many(identityVerificationCodes), + courierMessageDispatches: many(courierMessageDispatches), + identityLoginCodes: many(identityLoginCodes), + identityRegistrationCodes: many(identityRegistrationCodes), +})); + +export const selfserviceLoginFlowsRelations = relations(selfserviceLoginFlows, ({ one, many }) => ({ + network: one(networks, { + fields: [selfserviceLoginFlows.nid], + references: [networks.id], + }), + identityLoginCodes: many(identityLoginCodes), +})); + +export const selfserviceRegistrationFlowsRelations = relations(selfserviceRegistrationFlows, ({ one, many }) => ({ + network: one(networks, { + fields: [selfserviceRegistrationFlows.nid], + references: [networks.id], + }), + identityRegistrationCodes: many(identityRegistrationCodes), +})); + +export const identityCredentialIdentifiersRelations = relations(identityCredentialIdentifiers, ({ one }) => ({ + identityCredential: one(identityCredentials, { + fields: [identityCredentialIdentifiers.identityCredentialId], + references: [identityCredentials.id], + }), + network: one(networks, { + fields: [identityCredentialIdentifiers.nid], + references: [networks.id], + }), + identityCredentialType: one(identityCredentialTypes, { + fields: [identityCredentialIdentifiers.identityCredentialTypeId], + references: [identityCredentialTypes.id], + }), +})); + +export const identityVerifiableAddressesRelations = relations(identityVerifiableAddresses, ({ one, many }) => ({ + identity: one(identities, { + fields: [identityVerifiableAddresses.identityId], + references: [identities.id], + }), + network: one(networks, { + fields: [identityVerifiableAddresses.nid], + references: [networks.id], + }), + identityVerificationTokens: many(identityVerificationTokens), + identityVerificationCodes: many(identityVerificationCodes), +})); + +export const courierMessagesRelations = relations(courierMessages, ({ one, many }) => ({ + network: one(networks, { + fields: [courierMessages.nid], + references: [networks.id], + }), + courierMessageDispatches: many(courierMessageDispatches), +})); + +export const selfserviceErrorsRelations = relations(selfserviceErrors, ({ one }) => ({ + network: one(networks, { + fields: [selfserviceErrors.nid], + references: [networks.id], + }), +})); + +export const selfserviceVerificationFlowsRelations = relations(selfserviceVerificationFlows, ({ one, many }) => ({ + network: one(networks, { + fields: [selfserviceVerificationFlows.nid], + references: [networks.id], + }), + identityVerificationTokens: many(identityVerificationTokens), + identityVerificationCodes: many(identityVerificationCodes), +})); + +export const selfserviceSettingsFlowsRelations = relations(selfserviceSettingsFlows, ({ one }) => ({ + identity: one(identities, { + fields: [selfserviceSettingsFlows.identityId], + references: [identities.id], + }), + network: one(networks, { + fields: [selfserviceSettingsFlows.nid], + references: [networks.id], + }), +})); + +export const continuityContainersRelations = relations(continuityContainers, ({ one }) => ({ + identity: one(identities, { + fields: [continuityContainers.identityId], + references: [identities.id], + }), + network: one(networks, { + fields: [continuityContainers.nid], + references: [networks.id], + }), +})); + +export const sessionsRelations = relations(sessions, ({ one, many }) => ({ + identity: one(identities, { + fields: [sessions.identityId], + references: [identities.id], + }), + network: one(networks, { + fields: [sessions.nid], + references: [networks.id], + }), + sessionDevices: many(sessionDevices), +})); + +export const identityRecoveryAddressesRelations = relations(identityRecoveryAddresses, ({ one, many }) => ({ + identity: one(identities, { + fields: [identityRecoveryAddresses.identityId], + references: [identities.id], + }), + network: one(networks, { + fields: [identityRecoveryAddresses.nid], + references: [networks.id], + }), + identityRecoveryTokens: many(identityRecoveryTokens), + identityRecoveryCodes: many(identityRecoveryCodes), +})); + +export const identityVerificationTokensRelations = relations(identityVerificationTokens, ({ one }) => ({ + identityVerifiableAddress: one(identityVerifiableAddresses, { + fields: [identityVerificationTokens.identityVerifiableAddressId], + references: [identityVerifiableAddresses.id], + }), + selfserviceVerificationFlow: one(selfserviceVerificationFlows, { + fields: [identityVerificationTokens.selfserviceVerificationFlowId], + references: [selfserviceVerificationFlows.id], + }), + network: one(networks, { + fields: [identityVerificationTokens.nid], + references: [networks.id], + }), +})); + +export const selfserviceRecoveryFlowsRelations = relations(selfserviceRecoveryFlows, ({ one, many }) => ({ + identity: one(identities, { + fields: [selfserviceRecoveryFlows.recoveredIdentityId], + references: [identities.id], + }), + network: one(networks, { + fields: [selfserviceRecoveryFlows.nid], + references: [networks.id], + }), + identityRecoveryTokens: many(identityRecoveryTokens), + identityRecoveryCodes: many(identityRecoveryCodes), +})); + +export const identityRecoveryTokensRelations = relations(identityRecoveryTokens, ({ one }) => ({ + selfserviceRecoveryFlow: one(selfserviceRecoveryFlows, { + fields: [identityRecoveryTokens.selfserviceRecoveryFlowId], + references: [selfserviceRecoveryFlows.id], + }), + network: one(networks, { + fields: [identityRecoveryTokens.nid], + references: [networks.id], + }), + identityRecoveryAddress: one(identityRecoveryAddresses, { + fields: [identityRecoveryTokens.identityRecoveryAddressId], + references: [identityRecoveryAddresses.id], + }), + identity: one(identities, { + fields: [identityRecoveryTokens.identityId], + references: [identities.id], + }), +})); + +export const identityRecoveryCodesRelations = relations(identityRecoveryCodes, ({ one }) => ({ + identityRecoveryAddress: one(identityRecoveryAddresses, { + fields: [identityRecoveryCodes.identityRecoveryAddressId], + references: [identityRecoveryAddresses.id], + }), + selfserviceRecoveryFlow: one(selfserviceRecoveryFlows, { + fields: [identityRecoveryCodes.selfserviceRecoveryFlowId], + references: [selfserviceRecoveryFlows.id], + }), + identity: one(identities, { + fields: [identityRecoveryCodes.identityId], + references: [identities.id], + }), + network: one(networks, { + fields: [identityRecoveryCodes.nid], + references: [networks.id], + }), +})); + +export const sessionDevicesRelations = relations(sessionDevices, ({ one }) => ({ + session: one(sessions, { + fields: [sessionDevices.sessionId], + references: [sessions.id], + }), + network: one(networks, { + fields: [sessionDevices.nid], + references: [networks.id], + }), +})); + +export const identityVerificationCodesRelations = relations(identityVerificationCodes, ({ one }) => ({ + identityVerifiableAddress: one(identityVerifiableAddresses, { + fields: [identityVerificationCodes.identityVerifiableAddressId], + references: [identityVerifiableAddresses.id], + }), + selfserviceVerificationFlow: one(selfserviceVerificationFlows, { + fields: [identityVerificationCodes.selfserviceVerificationFlowId], + references: [selfserviceVerificationFlows.id], + }), + network: one(networks, { + fields: [identityVerificationCodes.nid], + references: [networks.id], + }), +})); + +export const courierMessageDispatchesRelations = relations(courierMessageDispatches, ({ one }) => ({ + courierMessage: one(courierMessages, { + fields: [courierMessageDispatches.messageId], + references: [courierMessages.id], + }), + network: one(networks, { + fields: [courierMessageDispatches.nid], + references: [networks.id], + }), +})); + +export const identityLoginCodesRelations = relations(identityLoginCodes, ({ one }) => ({ + selfserviceLoginFlow: one(selfserviceLoginFlows, { + fields: [identityLoginCodes.selfserviceLoginFlowId], + references: [selfserviceLoginFlows.id], + }), + network: one(networks, { + fields: [identityLoginCodes.nid], + references: [networks.id], + }), + identity: one(identities, { + fields: [identityLoginCodes.identityId], + references: [identities.id], + }), +})); + +export const identityRegistrationCodesRelations = relations(identityRegistrationCodes, ({ one }) => ({ + selfserviceRegistrationFlow: one(selfserviceRegistrationFlows, { + fields: [identityRegistrationCodes.selfserviceRegistrationFlowId], + references: [selfserviceRegistrationFlows.id], + }), + network: one(networks, { + fields: [identityRegistrationCodes.nid], + references: [networks.id], + }), +})); \ No newline at end of file diff --git a/dashboard/drizzle/schema.ts b/dashboard/drizzle/schema.ts index e69de29..4aa73e5 100644 --- a/dashboard/drizzle/schema.ts +++ b/dashboard/drizzle/schema.ts @@ -0,0 +1,713 @@ +import { + boolean, + char, + check, + foreignKey, + index, + integer, + json, + jsonb, + pgTable, + text, + timestamp, + unique, + uniqueIndex, + uuid, + varchar, +} from 'drizzle-orm/pg-core'; +import { sql } from 'drizzle-orm'; + +export const schemaMigration = pgTable('schema_migration', { + version: varchar({ length: 48 }).notNull(), + versionSelf: integer('version_self').default(0).notNull(), +}, (table) => [ + uniqueIndex('schema_migration_version_idx').using('btree', table.version.asc().nullsLast().op('text_ops')), + index('schema_migration_version_self_idx').using('btree', table.versionSelf.asc().nullsLast().op('int4_ops')), +]); + +export const identityCredentials = pgTable('identity_credentials', { + id: uuid().primaryKey().notNull(), + config: jsonb().notNull(), + identityCredentialTypeId: uuid('identity_credential_type_id').notNull(), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), + version: integer().default(0).notNull(), +}, (table) => [ + index('identity_credentials_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_credentials_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_credentials_nid_identity_id_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_credentials_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.identityCredentialTypeId], + foreignColumns: [identityCredentialTypes.id], + name: 'identity_credentials_identity_credential_type_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_credentials_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityCredentialTypes = pgTable('identity_credential_types', { + id: uuid().primaryKey().notNull(), + name: varchar({ length: 32 }).notNull(), +}, (table) => [ + uniqueIndex('identity_credential_types_name_idx').using('btree', table.name.asc().nullsLast().op('text_ops')), +]); + +export const selfserviceLoginFlows = pgTable('selfservice_login_flows', { + id: uuid().primaryKey().notNull(), + requestUrl: text('request_url').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + activeMethod: varchar('active_method', { length: 32 }).notNull(), + csrfToken: varchar('csrf_token', { length: 255 }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + forced: boolean().default(false).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + requestedAal: varchar('requested_aal', { length: 4 }).default('aal1').notNull(), + internalContext: jsonb('internal_context').notNull(), + oauth2LoginChallenge: uuid('oauth2_login_challenge'), + oauth2LoginChallengeData: text('oauth2_login_challenge_data'), + state: varchar({ length: 255 }), + submitCount: integer('submit_count').default(0).notNull(), + organizationId: uuid('organization_id'), +}, (table) => [ + index('selfservice_login_flows_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_login_flows_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_login_flows_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const networks = pgTable('networks', { + id: uuid().primaryKey().notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), +}); + +export const selfserviceRegistrationFlows = pgTable('selfservice_registration_flows', { + id: uuid().primaryKey().notNull(), + requestUrl: text('request_url').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + activeMethod: varchar('active_method', { length: 32 }).notNull(), + csrfToken: varchar('csrf_token', { length: 255 }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + internalContext: jsonb('internal_context').notNull(), + oauth2LoginChallenge: uuid('oauth2_login_challenge'), + oauth2LoginChallengeData: text('oauth2_login_challenge_data'), + state: varchar({ length: 255 }), + submitCount: integer('submit_count').default(0).notNull(), + organizationId: uuid('organization_id'), +}, (table) => [ + index('selfservice_registration_flows_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_registration_flows_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_registration_flows_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identities = pgTable('identities', { + id: uuid().primaryKey().notNull(), + schemaId: varchar('schema_id', { length: 2048 }).notNull(), + traits: jsonb().notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), + state: varchar({ length: 255 }).default('active').notNull(), + stateChangedAt: timestamp('state_changed_at', { mode: 'string' }), + metadataPublic: jsonb('metadata_public'), + metadataAdmin: jsonb('metadata_admin'), + availableAal: varchar('available_aal', { length: 4 }), + organizationId: uuid('organization_id'), +}, (table) => [ + index('identities_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identities_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identities_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityCredentialIdentifiers = pgTable('identity_credential_identifiers', { + id: uuid().primaryKey().notNull(), + identifier: varchar({ length: 255 }).notNull(), + identityCredentialId: uuid('identity_credential_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), + identityCredentialTypeId: uuid('identity_credential_type_id').notNull(), +}, (table) => [ + index('identity_credential_identifiers_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + uniqueIndex('identity_credential_identifiers_identifier_nid_type_uq_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.identityCredentialTypeId.asc().nullsLast().op('uuid_ops'), table.identifier.asc().nullsLast().op('uuid_ops')), + index('identity_credential_identifiers_nid_i_ici_idx').using('btree', table.nid.asc().nullsLast().op('text_ops'), table.identifier.asc().nullsLast().op('text_ops'), table.identityCredentialId.asc().nullsLast().op('text_ops')), + index('identity_credential_identifiers_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_credential_identifiers_nid_identity_credential_id_idx').using('btree', table.identityCredentialId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityCredentialId], + foreignColumns: [identityCredentials.id], + name: 'identity_credential_identifiers_identity_credential_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_credential_identifiers_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), + foreignKey({ + columns: [table.identityCredentialTypeId], + foreignColumns: [identityCredentialTypes.id], + name: 'identity_credential_identifiers_type_id_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityVerifiableAddresses = pgTable('identity_verifiable_addresses', { + id: uuid().primaryKey().notNull(), + status: varchar({ length: 16 }).notNull(), + via: varchar({ length: 16 }).notNull(), + verified: boolean().notNull(), + value: varchar({ length: 400 }).notNull(), + verifiedAt: timestamp('verified_at', { mode: 'string' }), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), +}, (table) => [ + index('identity_verifiable_addresses_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_verifiable_addresses_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_verifiable_addresses_nid_identity_id_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_verifiable_addresses_status_via_idx').using('btree', table.nid.asc().nullsLast().op('text_ops'), table.via.asc().nullsLast().op('text_ops'), table.value.asc().nullsLast().op('text_ops')), + uniqueIndex('identity_verifiable_addresses_status_via_uq_idx').using('btree', table.nid.asc().nullsLast().op('text_ops'), table.via.asc().nullsLast().op('text_ops'), table.value.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_verifiable_addresses_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_verifiable_addresses_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const courierMessages = pgTable('courier_messages', { + id: uuid().primaryKey().notNull(), + type: integer().notNull(), + status: integer().notNull(), + body: text().notNull(), + subject: varchar({ length: 255 }).notNull(), + recipient: varchar({ length: 255 }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + templateType: varchar('template_type', { length: 255 }).default('').notNull(), + // TODO: failed to parse database type 'bytea' + templateData: varchar('template_data'), + nid: uuid(), + sendCount: integer('send_count').default(0).notNull(), + channel: varchar({ length: 32 }), +}, (table) => [ + index('courier_messages_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('courier_messages_nid_created_at_id_idx').using('btree', table.nid.asc().nullsLast().op('timestamp_ops'), table.createdAt.desc().nullsFirst().op('uuid_ops')), + index('courier_messages_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('courier_messages_nid_recipient_created_at_id_idx').using('btree', table.nid.asc().nullsLast().op('timestamp_ops'), table.recipient.asc().nullsLast().op('text_ops'), table.createdAt.desc().nullsFirst().op('uuid_ops')), + index('courier_messages_nid_status_created_at_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.status.asc().nullsLast().op('timestamp_ops'), table.createdAt.desc().nullsFirst().op('uuid_ops')), + index('courier_messages_status_idx').using('btree', table.status.asc().nullsLast().op('int4_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'courier_messages_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const selfserviceErrors = pgTable('selfservice_errors', { + id: uuid().primaryKey().notNull(), + errors: jsonb().notNull(), + seenAt: timestamp('seen_at', { mode: 'string' }), + wasSeen: boolean('was_seen').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + csrfToken: varchar('csrf_token', { length: 255 }).default('').notNull(), + nid: uuid(), +}, (table) => [ + index('selfservice_errors_errors_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_errors_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const selfserviceVerificationFlows = pgTable('selfservice_verification_flows', { + id: uuid().primaryKey().notNull(), + requestUrl: text('request_url').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + csrfToken: varchar('csrf_token', { length: 255 }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + state: varchar({ length: 255 }).default('show_form').notNull(), + activeMethod: varchar('active_method', { length: 32 }), + ui: jsonb(), + nid: uuid(), + submitCount: integer('submit_count').default(0).notNull(), + oauth2LoginChallenge: text('oauth2_login_challenge'), + sessionId: uuid('session_id'), + identityId: uuid('identity_id'), + authenticationMethods: json('authentication_methods'), +}, (table) => [ + index('selfservice_verification_flows_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_verification_flows_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_verification_flows_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const selfserviceSettingsFlows = pgTable('selfservice_settings_flows', { + id: uuid().primaryKey().notNull(), + requestUrl: text('request_url').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + activeMethod: varchar('active_method', { length: 32 }), + state: varchar({ length: 255 }).default('show_form').notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + internalContext: jsonb('internal_context').notNull(), +}, (table) => [ + index('selfservice_settings_flows_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_settings_flows_identity_id_nid_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_settings_flows_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'selfservice_profile_management_requests_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_settings_flows_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const continuityContainers = pgTable('continuity_containers', { + id: uuid().primaryKey().notNull(), + identityId: uuid('identity_id'), + name: varchar({ length: 255 }).notNull(), + payload: jsonb(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), +}, (table) => [ + index('continuity_containers_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('continuity_containers_identity_id_nid_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('continuity_containers_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'continuity_containers_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'continuity_containers_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const sessions = pgTable('sessions', { + id: uuid().primaryKey().notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + authenticatedAt: timestamp('authenticated_at', { mode: 'string' }).notNull(), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + token: varchar({ length: 39 }), + active: boolean().default(false), + nid: uuid(), + logoutToken: varchar('logout_token', { length: 39 }), + aal: varchar({ length: 4 }).default('aal1').notNull(), + authenticationMethods: jsonb('authentication_methods').notNull(), +}, (table) => [ + index('sessions_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('sessions_identity_id_nid_sorted_idx').using('btree', table.identityId.asc().nullsLast().op('timestamp_ops'), table.nid.asc().nullsLast().op('timestamp_ops'), table.authenticatedAt.desc().nullsFirst().op('uuid_ops')), + uniqueIndex('sessions_logout_token_uq_idx').using('btree', table.logoutToken.asc().nullsLast().op('text_ops')), + index('sessions_nid_created_at_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.createdAt.desc().nullsFirst().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('sessions_nid_id_identity_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.identityId.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('sessions_token_nid_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.token.asc().nullsLast().op('text_ops')), + uniqueIndex('sessions_token_uq_idx').using('btree', table.token.asc().nullsLast().op('text_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'sessions_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'sessions_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityRecoveryAddresses = pgTable('identity_recovery_addresses', { + id: uuid().primaryKey().notNull(), + via: varchar({ length: 16 }).notNull(), + value: varchar({ length: 400 }).notNull(), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), +}, (table) => [ + index('identity_recovery_addresses_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_addresses_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_addresses_nid_identity_id_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_addresses_status_via_idx').using('btree', table.nid.asc().nullsLast().op('text_ops'), table.via.asc().nullsLast().op('text_ops'), table.value.asc().nullsLast().op('text_ops')), + uniqueIndex('identity_recovery_addresses_status_via_uq_idx').using('btree', table.nid.asc().nullsLast().op('text_ops'), table.via.asc().nullsLast().op('text_ops'), table.value.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_recovery_addresses_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_recovery_addresses_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityVerificationTokens = pgTable('identity_verification_tokens', { + id: uuid().primaryKey().notNull(), + token: varchar({ length: 64 }).notNull(), + used: boolean().default(false).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).notNull(), + identityVerifiableAddressId: uuid('identity_verifiable_address_id').notNull(), + selfserviceVerificationFlowId: uuid('selfservice_verification_flow_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), +}, (table) => [ + index('identity_verification_tokens_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_verification_tokens_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_verification_tokens_token_nid_used_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.token.asc().nullsLast().op('bool_ops'), table.used.asc().nullsLast().op('text_ops'), table.selfserviceVerificationFlowId.asc().nullsLast().op('uuid_ops')), + uniqueIndex('identity_verification_tokens_token_uq_idx').using('btree', table.token.asc().nullsLast().op('text_ops')), + index('identity_verification_tokens_verifiable_address_id_idx').using('btree', table.identityVerifiableAddressId.asc().nullsLast().op('uuid_ops')), + index('identity_verification_tokens_verification_flow_id_idx').using('btree', table.selfserviceVerificationFlowId.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityVerifiableAddressId], + foreignColumns: [identityVerifiableAddresses.id], + name: 'identity_verification_tokens_identity_verifiable_address_i_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.selfserviceVerificationFlowId], + foreignColumns: [selfserviceVerificationFlows.id], + name: 'identity_verification_tokens_selfservice_verification_flow_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_verification_tokens_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const selfserviceRecoveryFlows = pgTable('selfservice_recovery_flows', { + id: uuid().primaryKey().notNull(), + requestUrl: text('request_url').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + activeMethod: varchar('active_method', { length: 32 }), + csrfToken: varchar('csrf_token', { length: 255 }).notNull(), + state: varchar({ length: 32 }).notNull(), + recoveredIdentityId: uuid('recovered_identity_id'), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + submitCount: integer('submit_count').default(0).notNull(), + skipCsrfCheck: boolean('skip_csrf_check').default(false).notNull(), +}, (table) => [ + index('selfservice_recovery_flows_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_recovery_flows_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('selfservice_recovery_flows_recovered_identity_id_nid_idx').using('btree', table.recoveredIdentityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.recoveredIdentityId], + foreignColumns: [identities.id], + name: 'selfservice_recovery_requests_recovered_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_recovery_flows_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityRecoveryTokens = pgTable('identity_recovery_tokens', { + id: uuid().primaryKey().notNull(), + token: varchar({ length: 64 }).notNull(), + used: boolean().default(false).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + identityRecoveryAddressId: uuid('identity_recovery_address_id'), + selfserviceRecoveryFlowId: uuid('selfservice_recovery_flow_id'), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + nid: uuid(), + identityId: uuid('identity_id').notNull(), + tokenType: integer('token_type').default(0).notNull(), +}, (table) => [ + uniqueIndex('identity_recovery_addresses_code_uq_idx').using('btree', table.token.asc().nullsLast().op('text_ops')), + index('identity_recovery_tokens_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_identity_id_nid_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_identity_recovery_address_id_idx').using('btree', table.identityRecoveryAddressId.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_selfservice_recovery_flow_id_idx').using('btree', table.selfserviceRecoveryFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_token_nid_used_idx').using('btree', table.nid.asc().nullsLast().op('bool_ops'), table.token.asc().nullsLast().op('text_ops'), table.used.asc().nullsLast().op('bool_ops')), + foreignKey({ + columns: [table.selfserviceRecoveryFlowId], + foreignColumns: [selfserviceRecoveryFlows.id], + name: 'identity_recovery_tokens_selfservice_recovery_request_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_recovery_tokens_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), + foreignKey({ + columns: [table.identityRecoveryAddressId], + foreignColumns: [identityRecoveryAddresses.id], + name: 'identity_recovery_tokens_identity_recovery_address_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_recovery_tokens_identity_id_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), + check('identity_recovery_tokens_token_type_ck', sql`(token_type = 1) + OR (token_type = 2)`), +]); + +export const identityRecoveryCodes = pgTable('identity_recovery_codes', { + id: uuid().primaryKey().notNull(), + code: varchar({ length: 64 }).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + identityRecoveryAddressId: uuid('identity_recovery_address_id'), + codeType: integer('code_type').notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfserviceRecoveryFlowId: uuid('selfservice_recovery_flow_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid().notNull(), + identityId: uuid('identity_id').notNull(), +}, (table) => [ + index('identity_recovery_codes_flow_id_idx').using('btree', table.selfserviceRecoveryFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_codes_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_codes_identity_id_nid_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_codes_identity_recovery_address_id_nid_idx').using('btree', table.identityRecoveryAddressId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_codes_nid_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.selfserviceRecoveryFlowId.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityRecoveryAddressId], + foreignColumns: [identityRecoveryAddresses.id], + name: 'identity_recovery_codes_identity_recovery_addresses_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.selfserviceRecoveryFlowId], + foreignColumns: [selfserviceRecoveryFlows.id], + name: 'identity_recovery_codes_selfservice_recovery_flows_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_recovery_codes_identity_id_fk', + }).onUpdate('restrict').onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_recovery_codes_networks_id_fk', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const sessionDevices = pgTable('session_devices', { + id: uuid().primaryKey().notNull(), + ipAddress: varchar('ip_address', { length: 50 }).default(''), + userAgent: varchar('user_agent', { length: 512 }).default(''), + location: varchar({ length: 512 }).default(''), + nid: uuid().notNull(), + sessionId: uuid('session_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), +}, (table) => [ + index('session_devices_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('session_devices_session_id_nid_idx').using('btree', table.sessionId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.sessionId], + foreignColumns: [sessions.id], + name: 'session_metadata_sessions_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'session_metadata_nid_fk', + }).onDelete('cascade'), + unique('unique_session_device').on(table.ipAddress, table.userAgent, table.nid, table.sessionId), +]); + +export const identityVerificationCodes = pgTable('identity_verification_codes', { + id: uuid().primaryKey().notNull(), + codeHmac: varchar('code_hmac', { length: 64 }).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + identityVerifiableAddressId: uuid('identity_verifiable_address_id'), + expiresAt: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfserviceVerificationFlowId: uuid('selfservice_verification_flow_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid().notNull(), +}, (table) => [ + index('identity_verification_codes_flow_id_idx').using('btree', table.selfserviceVerificationFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_verification_codes_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_verification_codes_nid_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.selfserviceVerificationFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_verification_codes_verifiable_address_nid_idx').using('btree', table.identityVerifiableAddressId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityVerifiableAddressId], + foreignColumns: [identityVerifiableAddresses.id], + name: 'identity_verification_codes_identity_verifiable_addresses_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.selfserviceVerificationFlowId], + foreignColumns: [selfserviceVerificationFlows.id], + name: 'identity_verification_codes_selfservice_verification_flows_id_f', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_verification_codes_networks_id_fk', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const courierMessageDispatches = pgTable('courier_message_dispatches', { + id: uuid().primaryKey().notNull(), + messageId: uuid('message_id').notNull(), + status: varchar({ length: 7 }).notNull(), + error: json(), + nid: uuid().notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), +}, (table) => [ + index('courier_message_dispatches_message_id_idx').using('btree', table.messageId.asc().nullsLast().op('timestamp_ops'), table.createdAt.desc().nullsFirst().op('timestamp_ops')), + index('courier_message_dispatches_nid_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.messageId], + foreignColumns: [courierMessages.id], + name: 'courier_message_dispatches_message_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'courier_message_dispatches_nid_fk', + }).onDelete('cascade'), +]); + +export const sessionTokenExchanges = pgTable('session_token_exchanges', { + id: uuid().primaryKey().notNull(), + nid: uuid().notNull(), + flowId: uuid('flow_id').notNull(), + sessionId: uuid('session_id'), + initCode: varchar('init_code', { length: 64 }).notNull(), + returnToCode: varchar('return_to_code', { length: 64 }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), +}, (table) => [ + index('session_token_exchanges_nid_code_idx').using('btree', table.initCode.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('text_ops')), + index('session_token_exchanges_nid_flow_id_idx').using('btree', table.flowId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), +]); + +export const identityLoginCodes = pgTable('identity_login_codes', { + id: uuid().primaryKey().notNull(), + code: varchar({ length: 64 }).notNull(), + address: varchar({ length: 255 }).notNull(), + addressType: char('address_type', { length: 36 }).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + expiresAt: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfserviceLoginFlowId: uuid('selfservice_login_flow_id').notNull(), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + nid: uuid().notNull(), +}, (table) => [ + index('identity_login_codes_flow_id_idx').using('btree', table.selfserviceLoginFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_login_codes_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_login_codes_identity_id_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops')), + index('identity_login_codes_nid_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.selfserviceLoginFlowId.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.selfserviceLoginFlowId], + foreignColumns: [selfserviceLoginFlows.id], + name: 'identity_login_codes_selfservice_login_flows_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_login_codes_networks_id_fk', + }).onUpdate('restrict').onDelete('cascade'), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_login_codes_identity_id_fk', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityRegistrationCodes = pgTable('identity_registration_codes', { + id: uuid().primaryKey().notNull(), + code: varchar({ length: 64 }).notNull(), + address: varchar({ length: 255 }).notNull(), + addressType: char('address_type', { length: 36 }).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + expiresAt: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfserviceRegistrationFlowId: uuid('selfservice_registration_flow_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + nid: uuid().notNull(), +}, (table) => [ + index('identity_registration_codes_flow_id_idx').using('btree', table.selfserviceRegistrationFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_registration_codes_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_registration_codes_nid_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.selfserviceRegistrationFlowId.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.selfserviceRegistrationFlowId], + foreignColumns: [selfserviceRegistrationFlows.id], + name: 'identity_registration_codes_selfservice_registration_flows_id_f', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_registration_codes_networks_id_fk', + }).onUpdate('restrict').onDelete('cascade'), +]); diff --git a/dashboard/src/db/schema.ts b/dashboard/src/db/schema.ts index e69de29..5514575 100644 --- a/dashboard/src/db/schema.ts +++ b/dashboard/src/db/schema.ts @@ -0,0 +1,713 @@ +import { + boolean, + char, + check, + foreignKey, + index, + integer, + json, + jsonb, + pgTable, + text, + timestamp, + unique, + uniqueIndex, + uuid, + varchar, +} from 'drizzle-orm/pg-core'; +import { sql } from 'drizzle-orm'; + +export const schemaMigration = pgTable('schema_migration', { + version: varchar({ length: 48 }).notNull(), + versionSelf: integer('version_self').default(0).notNull(), +}, (table) => [ + uniqueIndex('schema_migration_version_idx').using('btree', table.version.asc().nullsLast().op('text_ops')), + index('schema_migration_version_self_idx').using('btree', table.versionSelf.asc().nullsLast().op('int4_ops')), +]); + +export const identityCredentials = pgTable('identity_credentials', { + id: uuid().primaryKey().notNull(), + config: jsonb().notNull(), + identityCredentialTypeId: uuid('identity_credential_type_id').notNull(), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), + version: integer().default(0).notNull(), +}, (table) => [ + index('identity_credentials_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_credentials_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_credentials_nid_identity_id_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_credentials_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.identityCredentialTypeId], + foreignColumns: [identityCredentialTypes.id], + name: 'identity_credentials_identity_credential_type_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_credentials_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityCredentialTypes = pgTable('identity_credential_types', { + id: uuid().primaryKey().notNull(), + name: varchar({ length: 32 }).notNull(), +}, (table) => [ + uniqueIndex('identity_credential_types_name_idx').using('btree', table.name.asc().nullsLast().op('text_ops')), +]); + +export const selfserviceLoginFlows = pgTable('selfservice_login_flows', { + id: uuid().primaryKey().notNull(), + requestUrl: text('request_url').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + activeMethod: varchar('active_method', { length: 32 }).notNull(), + csrfToken: varchar('csrf_token', { length: 255 }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + forced: boolean().default(false).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + requestedAal: varchar('requested_aal', { length: 4 }).default('aal1').notNull(), + internalContext: jsonb('internal_context').notNull(), + oauth2LoginChallenge: uuid('oauth2_login_challenge'), + oauth2LoginChallengeData: text('oauth2_login_challenge_data'), + state: varchar({ length: 255 }), + submitCount: integer('submit_count').default(0).notNull(), + organizationId: uuid('organization_id'), +}, (table) => [ + index('selfservice_login_flows_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_login_flows_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_login_flows_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const networks = pgTable('networks', { + id: uuid().primaryKey().notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), +}); + +export const selfserviceRegistrationFlows = pgTable('selfservice_registration_flows', { + id: uuid().primaryKey().notNull(), + requestUrl: text('request_url').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + activeMethod: varchar('active_method', { length: 32 }).notNull(), + csrfToken: varchar('csrf_token', { length: 255 }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + internalContext: jsonb('internal_context').notNull(), + oauth2LoginChallenge: uuid('oauth2_login_challenge'), + oauth2LoginChallengeData: text('oauth2_login_challenge_data'), + state: varchar({ length: 255 }), + submitCount: integer('submit_count').default(0).notNull(), + organizationId: uuid('organization_id'), +}, (table) => [ + index('selfservice_registration_flows_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_registration_flows_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_registration_flows_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identities = pgTable('identities', { + id: uuid().primaryKey().notNull(), + schemaId: varchar('schema_id', { length: 2048 }).notNull(), + traits: jsonb().notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), + state: varchar({ length: 255 }).default('active').notNull(), + stateChangedAt: timestamp('state_changed_at', { mode: 'string' }), + metadataPublic: jsonb('metadata_public'), + metadataAdmin: jsonb('metadata_admin'), + availableAal: varchar('available_aal', { length: 4 }), + organizationId: uuid('organization_id'), +}, (table) => [ + index('identities_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identities_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identities_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityCredentialIdentifiers = pgTable('identity_credential_identifiers', { + id: uuid().primaryKey().notNull(), + identifier: varchar({ length: 255 }).notNull(), + identityCredentialId: uuid('identity_credential_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), + identityCredentialTypeId: uuid('identity_credential_type_id').notNull(), +}, (table) => [ + index('identity_credential_identifiers_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + uniqueIndex('identity_credential_identifiers_identifier_nid_type_uq_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.identityCredentialTypeId.asc().nullsLast().op('uuid_ops'), table.identifier.asc().nullsLast().op('uuid_ops')), + index('identity_credential_identifiers_nid_i_ici_idx').using('btree', table.nid.asc().nullsLast().op('text_ops'), table.identifier.asc().nullsLast().op('text_ops'), table.identityCredentialId.asc().nullsLast().op('text_ops')), + index('identity_credential_identifiers_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_credential_identifiers_nid_identity_credential_id_idx').using('btree', table.identityCredentialId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityCredentialId], + foreignColumns: [identityCredentials.id], + name: 'identity_credential_identifiers_identity_credential_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_credential_identifiers_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), + foreignKey({ + columns: [table.identityCredentialTypeId], + foreignColumns: [identityCredentialTypes.id], + name: 'identity_credential_identifiers_type_id_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityVerifiableAddresses = pgTable('identity_verifiable_addresses', { + id: uuid().primaryKey().notNull(), + status: varchar({ length: 16 }).notNull(), + via: varchar({ length: 16 }).notNull(), + verified: boolean().notNull(), + value: varchar({ length: 400 }).notNull(), + verifiedAt: timestamp('verified_at', { mode: 'string' }), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), +}, (table) => [ + index('identity_verifiable_addresses_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_verifiable_addresses_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_verifiable_addresses_nid_identity_id_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_verifiable_addresses_status_via_idx').using('btree', table.nid.asc().nullsLast().op('text_ops'), table.via.asc().nullsLast().op('text_ops'), table.value.asc().nullsLast().op('text_ops')), + uniqueIndex('identity_verifiable_addresses_status_via_uq_idx').using('btree', table.nid.asc().nullsLast().op('text_ops'), table.via.asc().nullsLast().op('text_ops'), table.value.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_verifiable_addresses_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_verifiable_addresses_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const courierMessages = pgTable('courier_messages', { + id: uuid().primaryKey().notNull(), + type: integer().notNull(), + status: integer().notNull(), + body: text().notNull(), + subject: varchar({ length: 255 }).notNull(), + recipient: varchar({ length: 255 }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + templateType: varchar('template_type', { length: 255 }).default('').notNull(), + // TODO: failed to parse database type 'bytea' + templateData: varchar('template_data'), + nid: uuid(), + sendCount: integer('send_count').default(0).notNull(), + channel: varchar({ length: 32 }), +}, (table) => [ + index('courier_messages_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('courier_messages_nid_created_at_id_idx').using('btree', table.nid.asc().nullsLast().op('timestamp_ops'), table.createdAt.desc().nullsFirst().op('uuid_ops')), + index('courier_messages_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('courier_messages_nid_recipient_created_at_id_idx').using('btree', table.nid.asc().nullsLast().op('timestamp_ops'), table.recipient.asc().nullsLast().op('text_ops'), table.createdAt.desc().nullsFirst().op('uuid_ops')), + index('courier_messages_nid_status_created_at_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.status.asc().nullsLast().op('timestamp_ops'), table.createdAt.desc().nullsFirst().op('uuid_ops')), + index('courier_messages_status_idx').using('btree', table.status.asc().nullsLast().op('int4_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'courier_messages_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const selfserviceErrors = pgTable('selfservice_errors', { + id: uuid().primaryKey().notNull(), + errors: jsonb().notNull(), + seenAt: timestamp('seen_at', { mode: 'string' }), + wasSeen: boolean('was_seen').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + csrfToken: varchar('csrf_token', { length: 255 }).default('').notNull(), + nid: uuid(), +}, (table) => [ + index('selfservice_errors_errors_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_errors_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const selfserviceVerificationFlows = pgTable('selfservice_verification_flows', { + id: uuid().primaryKey().notNull(), + requestUrl: text('request_url').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + csrfToken: varchar('csrf_token', { length: 255 }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + state: varchar({ length: 255 }).default('show_form').notNull(), + activeMethod: varchar('active_method', { length: 32 }), + ui: jsonb(), + nid: uuid(), + submitCount: integer('submit_count').default(0).notNull(), + oauth2LoginChallenge: text('oauth2_login_challenge'), + sessionId: uuid('session_id'), + identityId: uuid('identity_id'), + authenticationMethods: json('authentication_methods'), +}, (table) => [ + index('selfservice_verification_flows_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_verification_flows_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_verification_flows_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const selfserviceSettingsFlows = pgTable('selfservice_settings_flows', { + id: uuid().primaryKey().notNull(), + requestUrl: text('request_url').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + activeMethod: varchar('active_method', { length: 32 }), + state: varchar({ length: 255 }).default('show_form').notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + internalContext: jsonb('internal_context').notNull(), +}, (table) => [ + index('selfservice_settings_flows_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_settings_flows_identity_id_nid_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_settings_flows_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'selfservice_profile_management_requests_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_settings_flows_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const continuityContainers = pgTable('continuity_containers', { + id: uuid().primaryKey().notNull(), + identityId: uuid('identity_id'), + name: varchar({ length: 255 }).notNull(), + payload: jsonb(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), +}, (table) => [ + index('continuity_containers_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('continuity_containers_identity_id_nid_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('continuity_containers_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'continuity_containers_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'continuity_containers_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const sessions = pgTable('sessions', { + id: uuid().primaryKey().notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + authenticatedAt: timestamp('authenticated_at', { mode: 'string' }).notNull(), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + token: varchar({ length: 39 }), + active: boolean().default(false), + nid: uuid(), + logoutToken: varchar('logout_token', { length: 39 }), + aal: varchar({ length: 4 }).default('aal1').notNull(), + authenticationMethods: jsonb('authentication_methods').notNull(), +}, (table) => [ + index('sessions_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('sessions_identity_id_nid_sorted_idx').using('btree', table.identityId.asc().nullsLast().op('timestamp_ops'), table.nid.asc().nullsLast().op('timestamp_ops'), table.authenticatedAt.desc().nullsFirst().op('uuid_ops')), + uniqueIndex('sessions_logout_token_uq_idx').using('btree', table.logoutToken.asc().nullsLast().op('text_ops')), + index('sessions_nid_created_at_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.createdAt.desc().nullsFirst().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('sessions_nid_id_identity_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.identityId.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('sessions_token_nid_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.token.asc().nullsLast().op('text_ops')), + uniqueIndex('sessions_token_uq_idx').using('btree', table.token.asc().nullsLast().op('text_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'sessions_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'sessions_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityRecoveryAddresses = pgTable('identity_recovery_addresses', { + id: uuid().primaryKey().notNull(), + via: varchar({ length: 16 }).notNull(), + value: varchar({ length: 400 }).notNull(), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), +}, (table) => [ + index('identity_recovery_addresses_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_addresses_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_addresses_nid_identity_id_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_addresses_status_via_idx').using('btree', table.nid.asc().nullsLast().op('text_ops'), table.via.asc().nullsLast().op('text_ops'), table.value.asc().nullsLast().op('text_ops')), + uniqueIndex('identity_recovery_addresses_status_via_uq_idx').using('btree', table.nid.asc().nullsLast().op('text_ops'), table.via.asc().nullsLast().op('text_ops'), table.value.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_recovery_addresses_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_recovery_addresses_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityVerificationTokens = pgTable('identity_verification_tokens', { + id: uuid().primaryKey().notNull(), + token: varchar({ length: 64 }).notNull(), + used: boolean().default(false).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).notNull(), + identityVerifiableAddressId: uuid('identity_verifiable_address_id').notNull(), + selfserviceVerificationFlowId: uuid('selfservice_verification_flow_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), +}, (table) => [ + index('identity_verification_tokens_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_verification_tokens_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_verification_tokens_token_nid_used_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.token.asc().nullsLast().op('bool_ops'), table.used.asc().nullsLast().op('text_ops'), table.selfserviceVerificationFlowId.asc().nullsLast().op('uuid_ops')), + uniqueIndex('identity_verification_tokens_token_uq_idx').using('btree', table.token.asc().nullsLast().op('text_ops')), + index('identity_verification_tokens_verifiable_address_id_idx').using('btree', table.identityVerifiableAddressId.asc().nullsLast().op('uuid_ops')), + index('identity_verification_tokens_verification_flow_id_idx').using('btree', table.selfserviceVerificationFlowId.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityVerifiableAddressId], + foreignColumns: [identityVerifiableAddresses.id], + name: 'identity_verification_tokens_identity_verifiable_address_i_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.selfserviceVerificationFlowId], + foreignColumns: [selfserviceVerificationFlows.id], + name: 'identity_verification_tokens_selfservice_verification_flow_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_verification_tokens_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const selfserviceRecoveryFlows = pgTable('selfservice_recovery_flows', { + id: uuid().primaryKey().notNull(), + requestUrl: text('request_url').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).notNull(), + activeMethod: varchar('active_method', { length: 32 }), + csrfToken: varchar('csrf_token', { length: 255 }).notNull(), + state: varchar({ length: 32 }).notNull(), + recoveredIdentityId: uuid('recovered_identity_id'), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + submitCount: integer('submit_count').default(0).notNull(), + skipCsrfCheck: boolean('skip_csrf_check').default(false).notNull(), +}, (table) => [ + index('selfservice_recovery_flows_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('selfservice_recovery_flows_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('selfservice_recovery_flows_recovered_identity_id_nid_idx').using('btree', table.recoveredIdentityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.recoveredIdentityId], + foreignColumns: [identities.id], + name: 'selfservice_recovery_requests_recovered_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'selfservice_recovery_flows_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityRecoveryTokens = pgTable('identity_recovery_tokens', { + id: uuid().primaryKey().notNull(), + token: varchar({ length: 64 }).notNull(), + used: boolean().default(false).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + identityRecoveryAddressId: uuid('identity_recovery_address_id'), + selfserviceRecoveryFlowId: uuid('selfservice_recovery_flow_id'), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + nid: uuid(), + identityId: uuid('identity_id').notNull(), + tokenType: integer('token_type').default(0).notNull(), +}, (table) => [ + uniqueIndex('identity_recovery_addresses_code_uq_idx').using('btree', table.token.asc().nullsLast().op('text_ops')), + index('identity_recovery_tokens_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_identity_id_nid_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_identity_recovery_address_id_idx').using('btree', table.identityRecoveryAddressId.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_nid_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.id.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_selfservice_recovery_flow_id_idx').using('btree', table.selfserviceRecoveryFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_token_nid_used_idx').using('btree', table.nid.asc().nullsLast().op('bool_ops'), table.token.asc().nullsLast().op('text_ops'), table.used.asc().nullsLast().op('bool_ops')), + foreignKey({ + columns: [table.selfserviceRecoveryFlowId], + foreignColumns: [selfserviceRecoveryFlows.id], + name: 'identity_recovery_tokens_selfservice_recovery_request_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_recovery_tokens_nid_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), + foreignKey({ + columns: [table.identityRecoveryAddressId], + foreignColumns: [identityRecoveryAddresses.id], + name: 'identity_recovery_tokens_identity_recovery_address_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_recovery_tokens_identity_id_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), + check('identity_recovery_tokens_token_type_ck', sql`(token_type = 1) + OR (token_type = 2)`), +]); + +export const identityRecoveryCodes = pgTable('identity_recovery_codes', { + id: uuid().primaryKey().notNull(), + code: varchar({ length: 64 }).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + identityRecoveryAddressId: uuid('identity_recovery_address_id'), + codeType: integer('code_type').notNull(), + expiresAt: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfserviceRecoveryFlowId: uuid('selfservice_recovery_flow_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid().notNull(), + identityId: uuid('identity_id').notNull(), +}, (table) => [ + index('identity_recovery_codes_flow_id_idx').using('btree', table.selfserviceRecoveryFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_codes_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_codes_identity_id_nid_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_codes_identity_recovery_address_id_nid_idx').using('btree', table.identityRecoveryAddressId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_codes_nid_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.selfserviceRecoveryFlowId.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityRecoveryAddressId], + foreignColumns: [identityRecoveryAddresses.id], + name: 'identity_recovery_codes_identity_recovery_addresses_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.selfserviceRecoveryFlowId], + foreignColumns: [selfserviceRecoveryFlows.id], + name: 'identity_recovery_codes_selfservice_recovery_flows_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_recovery_codes_identity_id_fk', + }).onUpdate('restrict').onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_recovery_codes_networks_id_fk', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const sessionDevices = pgTable('session_devices', { + id: uuid().primaryKey().notNull(), + ipAddress: varchar('ip_address', { length: 50 }).default(''), + userAgent: varchar('user_agent', { length: 512 }).default(''), + location: varchar({ length: 512 }).default(''), + nid: uuid().notNull(), + sessionId: uuid('session_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), +}, (table) => [ + index('session_devices_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('session_devices_session_id_nid_idx').using('btree', table.sessionId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.sessionId], + foreignColumns: [sessions.id], + name: 'session_metadata_sessions_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'session_metadata_nid_fk', + }).onDelete('cascade'), + unique('unique_session_device').on(table.ipAddress, table.userAgent, table.nid, table.sessionId), +]); + +export const identityVerificationCodes = pgTable('identity_verification_codes', { + id: uuid().primaryKey().notNull(), + codeHmac: varchar('code_hmac', { length: 64 }).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + identityVerifiableAddressId: uuid('identity_verifiable_address_id'), + expiresAt: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfserviceVerificationFlowId: uuid('selfservice_verification_flow_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid().notNull(), +}, (table) => [ + index('identity_verification_codes_flow_id_idx').using('btree', table.selfserviceVerificationFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_verification_codes_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_verification_codes_nid_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.selfserviceVerificationFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_verification_codes_verifiable_address_nid_idx').using('btree', table.identityVerifiableAddressId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identityVerifiableAddressId], + foreignColumns: [identityVerifiableAddresses.id], + name: 'identity_verification_codes_identity_verifiable_addresses_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.selfserviceVerificationFlowId], + foreignColumns: [selfserviceVerificationFlows.id], + name: 'identity_verification_codes_selfservice_verification_flows_id_f', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_verification_codes_networks_id_fk', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const courierMessageDispatches = pgTable('courier_message_dispatches', { + id: uuid().primaryKey().notNull(), + messageId: uuid('message_id').notNull(), + status: varchar({ length: 7 }).notNull(), + error: json(), + nid: uuid().notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), +}, (table) => [ + index('courier_message_dispatches_message_id_idx').using('btree', table.messageId.asc().nullsLast().op('timestamp_ops'), table.createdAt.desc().nullsFirst().op('timestamp_ops')), + index('courier_message_dispatches_nid_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.messageId], + foreignColumns: [courierMessages.id], + name: 'courier_message_dispatches_message_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'courier_message_dispatches_nid_fk', + }).onDelete('cascade'), +]); + +export const sessionTokenExchanges = pgTable('session_token_exchanges', { + id: uuid().primaryKey().notNull(), + nid: uuid().notNull(), + flowId: uuid('flow_id').notNull(), + sessionId: uuid('session_id'), + initCode: varchar('init_code', { length: 64 }).notNull(), + returnToCode: varchar('return_to_code', { length: 64 }).notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).notNull(), +}, (table) => [ + index('session_token_exchanges_nid_code_idx').using('btree', table.initCode.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('text_ops')), + index('session_token_exchanges_nid_flow_id_idx').using('btree', table.flowId.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), +]); + +export const identityLoginCodes = pgTable('identity_login_codes', { + id: uuid().primaryKey().notNull(), + code: varchar({ length: 64 }).notNull(), + address: varchar({ length: 255 }).notNull(), + addressType: char('address_type', { length: 36 }).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + expiresAt: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfserviceLoginFlowId: uuid('selfservice_login_flow_id').notNull(), + identityId: uuid('identity_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + nid: uuid().notNull(), +}, (table) => [ + index('identity_login_codes_flow_id_idx').using('btree', table.selfserviceLoginFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_login_codes_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_login_codes_identity_id_idx').using('btree', table.identityId.asc().nullsLast().op('uuid_ops')), + index('identity_login_codes_nid_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.selfserviceLoginFlowId.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.selfserviceLoginFlowId], + foreignColumns: [selfserviceLoginFlows.id], + name: 'identity_login_codes_selfservice_login_flows_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_login_codes_networks_id_fk', + }).onUpdate('restrict').onDelete('cascade'), + foreignKey({ + columns: [table.identityId], + foreignColumns: [identities.id], + name: 'identity_login_codes_identity_id_fk', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identityRegistrationCodes = pgTable('identity_registration_codes', { + id: uuid().primaryKey().notNull(), + code: varchar({ length: 64 }).notNull(), + address: varchar({ length: 255 }).notNull(), + addressType: char('address_type', { length: 36 }).notNull(), + usedAt: timestamp('used_at', { mode: 'string' }), + expiresAt: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issuedAt: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfserviceRegistrationFlowId: uuid('selfservice_registration_flow_id').notNull(), + createdAt: timestamp('created_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + updatedAt: timestamp('updated_at', { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + nid: uuid().notNull(), +}, (table) => [ + index('identity_registration_codes_flow_id_idx').using('btree', table.selfserviceRegistrationFlowId.asc().nullsLast().op('uuid_ops')), + index('identity_registration_codes_id_nid_idx').using('btree', table.id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_registration_codes_nid_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.selfserviceRegistrationFlowId.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.selfserviceRegistrationFlowId], + foreignColumns: [selfserviceRegistrationFlows.id], + name: 'identity_registration_codes_selfservice_registration_flows_id_f', + }).onDelete('cascade'), + foreignKey({ + columns: [table.nid], + foreignColumns: [networks.id], + name: 'identity_registration_codes_networks_id_fk', + }).onUpdate('restrict').onDelete('cascade'), +]);