diff --git a/dashboard/.env.example b/dashboard/.env.example index 0890e33..fbb1831 100644 --- a/dashboard/.env.example +++ b/dashboard/.env.example @@ -1,4 +1,6 @@ +DATABASE_URL=postgresql://postgres:postgres@localhost:5432/kratos + ORY_KRATOS_ADMIN_URL=http://localhost:4434 ORY_HYDRA_ADMIN_URL=http://localhost:4445 diff --git a/dashboard/bun.lockb b/dashboard/bun.lockb index ec6a87b..457965a 100755 Binary files a/dashboard/bun.lockb and b/dashboard/bun.lockb differ diff --git a/dashboard/drizzle.config.ts b/dashboard/drizzle.config.ts new file mode 100644 index 0000000..21ed5ad --- /dev/null +++ b/dashboard/drizzle.config.ts @@ -0,0 +1,14 @@ +'use server'; + +import 'dotenv/config'; +import { defineConfig } from 'drizzle-kit'; + + +export default defineConfig({ + out: './drizzle', + schema: './src/db/schema.ts', + dialect: 'postgresql', + dbCredentials: { + url: process.env.DATABASE_URL!, + }, +}); 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 new file mode 100644 index 0000000..615b353 --- /dev/null +++ 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 new file mode 100644 index 0000000..4bd317b --- /dev/null +++ b/dashboard/drizzle/schema.ts @@ -0,0 +1,714 @@ +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 schema_migration = pgTable('schema_migration', { + version: varchar({ length: 48 }).notNull(), + version_self: 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.version_self.asc().nullsLast().op('int4_ops')), +]); + +export const identity_credentials = pgTable('identity_credentials', { + id: uuid().primaryKey().notNull(), + config: jsonb().notNull(), + identity_credential_type_id: uuid('identity_credential_type_id').notNull(), + identity_id: uuid('identity_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: 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.identity_id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identity_id], + foreignColumns: [identities.id], + name: 'identity_credentials_identity_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.identity_credential_type_id], + foreignColumns: [identity_credential_types.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 identity_credential_types = 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 selfservice_login_flows = pgTable('selfservice_login_flows', { + id: uuid().primaryKey().notNull(), + request_url: text('request_url').notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + expires_at: timestamp('expires_at', { mode: 'string' }).notNull(), + active_method: varchar('active_method', { length: 32 }).notNull(), + csrf_token: varchar('csrf_token', { length: 255 }).notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + forced: boolean().default(false).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + requested_aal: varchar('requested_aal', { length: 4 }).default('aal1').notNull(), + internal_context: jsonb('internal_context').notNull(), + oauth2login_challenge: uuid('oauth2_login_challenge'), + oauth2login_challenge_data: text('oauth2_login_challenge_data'), + state: varchar({ length: 255 }), + submit_count: integer('submit_count').default(0).notNull(), + organization_id: 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(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), +}); + +export const selfservice_registration_flows = pgTable('selfservice_registration_flows', { + id: uuid().primaryKey().notNull(), + request_url: text('request_url').notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + expires_at: timestamp('expires_at', { mode: 'string' }).notNull(), + active_method: varchar('active_method', { length: 32 }).notNull(), + csrf_token: varchar('csrf_token', { length: 255 }).notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + internal_context: jsonb('internal_context').notNull(), + oauth2login_challenge: uuid('oauth2_login_challenge'), + oauth2login_challenge_data: text('oauth2_login_challenge_data'), + state: varchar({ length: 255 }), + submit_count: integer('submit_count').default(0).notNull(), + organization_id: 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(), + schema_id: varchar('schema_id', { length: 2048 }).notNull(), + traits: jsonb().notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), + state: varchar({ length: 255 }).default('active').notNull(), + state_changed_at: timestamp('state_changed_at', { mode: 'string' }), + metadata_public: jsonb('metadata_public'), + metadata_admin: jsonb('metadata_admin'), + available_aal: varchar('available_aal', { length: 4 }), + organization_id: 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 identity_credential_identifiers = pgTable('identity_credential_identifiers', { + id: uuid().primaryKey().notNull(), + identifier: varchar({ length: 255 }).notNull(), + identity_credential_id: uuid('identity_credential_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid(), + identity_credential_type_id: 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.identity_credential_type_id.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.identity_credential_id.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.identity_credential_id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identity_credential_id], + foreignColumns: [identity_credentials.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.identity_credential_type_id], + foreignColumns: [identity_credential_types.id], + name: 'identity_credential_identifiers_type_id_fk_idx', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identity_verifiable_addresses = 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(), + verified_at: timestamp('verified_at', { mode: 'string' }), + identity_id: uuid('identity_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: 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.identity_id.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.identity_id], + 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 courier_messages = 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(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + template_type: varchar('template_type', { length: 255 }).default('').notNull(), + // todo: failed to parse database type 'bytea' + template_data: varchar('template_data'), + nid: uuid(), + send_count: 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.created_at.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.created_at.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.created_at.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 selfservice_errors = pgTable('selfservice_errors', { + id: uuid().primaryKey().notNull(), + errors: jsonb().notNull(), + seen_at: timestamp('seen_at', { mode: 'string' }), + was_seen: boolean('was_seen').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + csrf_token: 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 selfservice_verification_flows = pgTable('selfservice_verification_flows', { + id: uuid().primaryKey().notNull(), + request_url: text('request_url').notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + expires_at: timestamp('expires_at', { mode: 'string' }).notNull(), + csrf_token: varchar('csrf_token', { length: 255 }).notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + state: varchar({ length: 255 }).default('show_form').notNull(), + active_method: varchar('active_method', { length: 32 }), + ui: jsonb(), + nid: uuid(), + submit_count: integer('submit_count').default(0).notNull(), + oauth2login_challenge: text('oauth2_login_challenge'), + session_id: uuid('session_id'), + identity_id: uuid('identity_id'), + authentication_methods: 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 selfservice_settings_flows = pgTable('selfservice_settings_flows', { + id: uuid().primaryKey().notNull(), + request_url: text('request_url').notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + expires_at: timestamp('expires_at', { mode: 'string' }).notNull(), + identity_id: uuid('identity_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + active_method: varchar('active_method', { length: 32 }), + state: varchar({ length: 255 }).default('show_form').notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + internal_context: 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.identity_id.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.identity_id], + 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 continuity_containers = pgTable('continuity_containers', { + id: uuid().primaryKey().notNull(), + identity_id: uuid('identity_id'), + name: varchar({ length: 255 }).notNull(), + payload: jsonb(), + expires_at: timestamp('expires_at', { mode: 'string' }).notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: 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.identity_id.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.identity_id], + 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(), + issued_at: timestamp('issued_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + expires_at: timestamp('expires_at', { mode: 'string' }).notNull(), + authenticated_at: timestamp('authenticated_at', { mode: 'string' }).notNull(), + identity_id: uuid('identity_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + token: varchar({ length: 39 }), + active: boolean().default(false), + nid: uuid(), + logout_token: varchar('logout_token', { length: 39 }), + aal: varchar({ length: 4 }).default('aal1').notNull(), + authentication_methods: 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.identity_id.asc().nullsLast().op('timestamp_ops'), table.nid.asc().nullsLast().op('timestamp_ops'), table.authenticated_at.desc().nullsFirst().op('uuid_ops')), + uniqueIndex('sessions_logout_token_uq_idx').using('btree', table.logout_token.asc().nullsLast().op('text_ops')), + index('sessions_nid_created_at_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.created_at.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.identity_id.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.identity_id], + 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 identity_recovery_addresses = pgTable('identity_recovery_addresses', { + id: uuid().primaryKey().notNull(), + via: varchar({ length: 16 }).notNull(), + value: varchar({ length: 400 }).notNull(), + identity_id: uuid('identity_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: 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.identity_id.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.identity_id], + 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 identity_verification_tokens = pgTable('identity_verification_tokens', { + id: uuid().primaryKey().notNull(), + token: varchar({ length: 64 }).notNull(), + used: boolean().default(false).notNull(), + used_at: timestamp('used_at', { mode: 'string' }), + expires_at: timestamp('expires_at', { mode: 'string' }).notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).notNull(), + identity_verifiable_address_id: uuid('identity_verifiable_address_id').notNull(), + selfservice_verification_flow_id: uuid('selfservice_verification_flow_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: 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.selfservice_verification_flow_id.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.identity_verifiable_address_id.asc().nullsLast().op('uuid_ops')), + index('identity_verification_tokens_verification_flow_id_idx').using('btree', table.selfservice_verification_flow_id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identity_verifiable_address_id], + foreignColumns: [identity_verifiable_addresses.id], + name: 'identity_verification_tokens_identity_verifiable_address_i_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.selfservice_verification_flow_id], + foreignColumns: [selfservice_verification_flows.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 selfservice_recovery_flows = pgTable('selfservice_recovery_flows', { + id: uuid().primaryKey().notNull(), + request_url: text('request_url').notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + expires_at: timestamp('expires_at', { mode: 'string' }).notNull(), + active_method: varchar('active_method', { length: 32 }), + csrf_token: varchar('csrf_token', { length: 255 }).notNull(), + state: varchar({ length: 32 }).notNull(), + recovered_identity_id: uuid('recovered_identity_id'), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + type: varchar({ length: 16 }).default('browser').notNull(), + ui: jsonb(), + nid: uuid(), + submit_count: integer('submit_count').default(0).notNull(), + skip_csrf_check: 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.recovered_identity_id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.recovered_identity_id], + 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 identity_recovery_tokens = pgTable('identity_recovery_tokens', { + id: uuid().primaryKey().notNull(), + token: varchar({ length: 64 }).notNull(), + used: boolean().default(false).notNull(), + used_at: timestamp('used_at', { mode: 'string' }), + identity_recovery_address_id: uuid('identity_recovery_address_id'), + selfservice_recovery_flow_id: uuid('selfservice_recovery_flow_id'), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + expires_at: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + nid: uuid(), + identity_id: uuid('identity_id').notNull(), + token_type: 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.identity_id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + index('identity_recovery_tokens_identity_recovery_address_id_idx').using('btree', table.identity_recovery_address_id.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.selfservice_recovery_flow_id.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.selfservice_recovery_flow_id], + foreignColumns: [selfservice_recovery_flows.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.identity_recovery_address_id], + foreignColumns: [identity_recovery_addresses.id], + name: 'identity_recovery_tokens_identity_recovery_address_id_fkey', + }).onDelete('cascade'), + foreignKey({ + columns: [table.identity_id], + 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 identity_recovery_codes = pgTable('identity_recovery_codes', { + id: uuid().primaryKey().notNull(), + code: varchar({ length: 64 }).notNull(), + used_at: timestamp('used_at', { mode: 'string' }), + identity_recovery_address_id: uuid('identity_recovery_address_id'), + code_type: integer('code_type').notNull(), + expires_at: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfservice_recovery_flow_id: uuid('selfservice_recovery_flow_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid().notNull(), + identity_id: uuid('identity_id').notNull(), +}, (table) => [ + index('identity_recovery_codes_flow_id_idx').using('btree', table.selfservice_recovery_flow_id.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.identity_id.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.identity_recovery_address_id.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.selfservice_recovery_flow_id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identity_recovery_address_id], + foreignColumns: [identity_recovery_addresses.id], + name: 'identity_recovery_codes_identity_recovery_addresses_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.selfservice_recovery_flow_id], + foreignColumns: [selfservice_recovery_flows.id], + name: 'identity_recovery_codes_selfservice_recovery_flows_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.identity_id], + 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 session_devices = pgTable('session_devices', { + id: uuid().primaryKey().notNull(), + ip_address: varchar('ip_address', { length: 50 }).default(''), + user_agent: varchar('user_agent', { length: 512 }).default(''), + location: varchar({ length: 512 }).default(''), + nid: uuid().notNull(), + session_id: uuid('session_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: 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.session_id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.session_id], + 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.ip_address, table.user_agent, table.nid, table.session_id), +]); + +export const identity_verification_codes = pgTable('identity_verification_codes', { + id: uuid().primaryKey().notNull(), + code_hmac: varchar('code_hmac', { length: 64 }).notNull(), + used_at: timestamp('used_at', { mode: 'string' }), + identity_verifiable_address_id: uuid('identity_verifiable_address_id'), + expires_at: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfservice_verification_flow_id: uuid('selfservice_verification_flow_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), + nid: uuid().notNull(), +}, (table) => [ + index('identity_verification_codes_flow_id_idx').using('btree', table.selfservice_verification_flow_id.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.selfservice_verification_flow_id.asc().nullsLast().op('uuid_ops')), + index('identity_verification_codes_verifiable_address_nid_idx').using('btree', table.identity_verifiable_address_id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.identity_verifiable_address_id], + foreignColumns: [identity_verifiable_addresses.id], + name: 'identity_verification_codes_identity_verifiable_addresses_id_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.selfservice_verification_flow_id], + foreignColumns: [selfservice_verification_flows.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 courier_message_dispatches = pgTable('courier_message_dispatches', { + id: uuid().primaryKey().notNull(), + message_id: uuid('message_id').notNull(), + status: varchar({ length: 7 }).notNull(), + error: json(), + nid: uuid().notNull(), + created_at: timestamp('created_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), +}, (table) => [ + index('courier_message_dispatches_message_id_idx').using('btree', table.message_id.asc().nullsLast().op('timestamp_ops'), table.created_at.desc().nullsFirst().op('timestamp_ops')), + index('courier_message_dispatches_nid_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.message_id], + foreignColumns: [courier_messages.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 session_token_exchanges = pgTable('session_token_exchanges', { + id: uuid().primaryKey().notNull(), + nid: uuid().notNull(), + flow_id: uuid('flow_id').notNull(), + session_id: uuid('session_id'), + init_code: varchar('init_code', { length: 64 }).notNull(), + return_to_code: varchar('return_to_code', { length: 64 }).notNull(), + created_at: timestamp('created_at', { mode: 'string' }).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).notNull(), +}, (table) => [ + index('session_token_exchanges_nid_code_idx').using('btree', table.init_code.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('text_ops')), + index('session_token_exchanges_nid_flow_id_idx').using('btree', table.flow_id.asc().nullsLast().op('uuid_ops'), table.nid.asc().nullsLast().op('uuid_ops')), +]); + +export const identity_login_codes = pgTable('identity_login_codes', { + id: uuid().primaryKey().notNull(), + code: varchar({ length: 64 }).notNull(), + address: varchar({ length: 255 }).notNull(), + address_type: char('address_type', { length: 36 }).notNull(), + used_at: timestamp('used_at', { mode: 'string' }), + expires_at: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfservice_login_flow_id: uuid('selfservice_login_flow_id').notNull(), + identity_id: uuid('identity_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + nid: uuid().notNull(), +}, (table) => [ + index('identity_login_codes_flow_id_idx').using('btree', table.selfservice_login_flow_id.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.identity_id.asc().nullsLast().op('uuid_ops')), + index('identity_login_codes_nid_flow_id_idx').using('btree', table.nid.asc().nullsLast().op('uuid_ops'), table.selfservice_login_flow_id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.selfservice_login_flow_id], + foreignColumns: [selfservice_login_flows.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.identity_id], + foreignColumns: [identities.id], + name: 'identity_login_codes_identity_id_fk', + }).onUpdate('restrict').onDelete('cascade'), +]); + +export const identity_registration_codes = pgTable('identity_registration_codes', { + id: uuid().primaryKey().notNull(), + code: varchar({ length: 64 }).notNull(), + address: varchar({ length: 255 }).notNull(), + address_type: char('address_type', { length: 36 }).notNull(), + used_at: timestamp('used_at', { mode: 'string' }), + expires_at: timestamp('expires_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + issued_at: timestamp('issued_at', { mode: 'string' }).default('2000-01-01 00:00:00').notNull(), + selfservice_registration_flow_id: uuid('selfservice_registration_flow_id').notNull(), + created_at: timestamp('created_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + updated_at: timestamp('updated_at', { mode: 'string' }).default(sql`current_timestamp`).notNull(), + nid: uuid().notNull(), +}, (table) => [ + index('identity_registration_codes_flow_id_idx').using('btree', table.selfservice_registration_flow_id.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.selfservice_registration_flow_id.asc().nullsLast().op('uuid_ops')), + foreignKey({ + columns: [table.selfservice_registration_flow_id], + foreignColumns: [selfservice_registration_flows.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/package.json b/dashboard/package.json index 4e18553..9641b8b 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -20,7 +20,7 @@ "@radix-ui/react-label": "^2.0.2", "@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-separator": "^1.1.0", - "@radix-ui/react-slot": "^1.1.0", + "@radix-ui/react-slot": "^1.1.1", "@radix-ui/react-tabs": "^1.1.1", "@radix-ui/react-tooltip": "^1.1.4", "@serwist/next": "^9.0.0-preview.21", @@ -30,10 +30,13 @@ "@tanstack/react-table": "^8.20.5", "class-variance-authority": "^0.7.1", "clsx": "^2.1.0", + "dotenv": "^16.4.7", + "drizzle-orm": "^0.38.3", "lucide-react": "^0.462.0", "next": "15.0.3", "next-themes": "^0.4.3", "oslo": "^1.1.3", + "pg": "^8.13.1", "react": "19.0.0-rc-66855b96-20241106", "react-dom": "19.0.0-rc-66855b96-20241106", "react-hook-form": "^7.51.0", @@ -48,14 +51,17 @@ }, "devDependencies": { "@types/node": "^22.9.3", + "@types/pg": "^8.11.10", "@types/react": "npm:types-react@19.0.0-rc.1", "@types/react-dom": "npm:types-react-dom@19.0.0-rc.1", "autoprefixer": "^10.0.1", + "drizzle-kit": "^0.30.1", "eslint": "^8", "eslint-config-next": "15.0.3", "postcss": "^8", "tailwindcss": "^3.3.0", "ts-node": "^10.9.2", + "tsx": "^4.19.2", "typescript": "^5.4.2" }, "overrides": { diff --git a/dashboard/src/app/(inside)/user/data-table.tsx b/dashboard/src/app/(inside)/user/data-table.tsx index 8f4e3ac..510ee6c 100644 --- a/dashboard/src/app/(inside)/user/data-table.tsx +++ b/dashboard/src/app/(inside)/user/data-table.tsx @@ -4,9 +4,7 @@ import { ColumnDef } from '@tanstack/react-table'; import { Identity } from '@ory/client'; import { DataTable } from '@/components/ui/data-table'; import { CircleCheck, CircleX, Copy, MoreHorizontal, Trash, UserCheck, UserMinus, UserPen, UserX } from 'lucide-react'; -import React, { useEffect, useRef, useState } from 'react'; -import { FetchIdentityPageProps } from '@/app/(inside)/user/page'; -import { Spinner } from '@/components/ui/spinner'; +import React, { useEffect, useState } from 'react'; import { DropdownMenu, DropdownMenuContent, @@ -33,13 +31,11 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip interface IdentityDataTableProps { data: Identity[]; - pageSize: number; - pageToken: string | undefined; + page: number; query: string; - fetchIdentityPage: (props: FetchIdentityPageProps) => Promise<{ data: Identity[], tokens: Map }>; } -export function IdentityDataTable({ data, pageSize, pageToken, query, fetchIdentityPage }: IdentityDataTableProps) { +export function IdentityDataTable({ data, page, query }: IdentityDataTableProps) { const columns: ColumnDef[] = [ { @@ -81,27 +77,24 @@ export function IdentityDataTable({ data, pageSize, pageToken, query, fetchIdent return (
{email.value} - { - email.verified ? - - - - - - This email was confirmed at - {new Date(email.verified_at!!).toLocaleString()} - - - : - - - - - - This email is not confirmed yet - - - } + + + { + email.verified ? : + } + + + { + email.verified ? + <> + This email was confirmed at + {new Date(email.verified_at!!).toLocaleString()} + + : +

This email is not confirmed yet

+ } +
+
); } @@ -189,49 +182,10 @@ export function IdentityDataTable({ data, pageSize, pageToken, query, fetchIdent ]; const [items, setItems] = useState(data); - const [nextToken, setNextToken] = useState(pageToken); - // react on changes from ssr (query params) useEffect(() => { setItems(data); - setNextToken(pageToken); - }, [data, pageSize, pageToken, query]); - - // infinite scroll handling - const infiniteScrollSensor = useRef(null); - useEffect(() => { - const observer = new IntersectionObserver( - (entries) => { - if (entries[0].isIntersecting) { - fetchMore(); - } - }, - { threshold: 0.5 }, // Adjust threshold as needed - ); - - if (infiniteScrollSensor.current) { - observer.observe(infiniteScrollSensor.current); - } - - return () => { - if (infiniteScrollSensor.current) { - observer.unobserve(infiniteScrollSensor.current); - } - }; - }, [items]); - - const fetchMore = async () => { - if (!nextToken) return; - - const response = await fetchIdentityPage({ - pageSize: pageSize, - pageToken: nextToken, - query: query, - }); - - setItems([...items, ...response.data]); - setNextToken(response.tokens.get('next') ?? undefined); - }; + }, [data]); // quick actions const [currentIdentity, setCurrentIdentity] = useState(undefined); @@ -341,13 +295,6 @@ export function IdentityDataTable({ data, pageSize, pageToken, query, fetchIdent ) } - { - nextToken && ( -
- -
- ) - } ); } diff --git a/dashboard/src/app/(inside)/user/page.tsx b/dashboard/src/app/(inside)/user/page.tsx index f02c636..efb1095 100644 --- a/dashboard/src/app/(inside)/user/page.tsx +++ b/dashboard/src/app/(inside)/user/page.tsx @@ -1,49 +1,8 @@ import React from 'react'; import { IdentityDataTable } from '@/app/(inside)/user/data-table'; -import { getIdentityApi } from '@/ory/sdk/server'; import { SearchInput } from '@/components/search-input'; - -export interface FetchIdentityPageProps { - pageSize: number; - pageToken: string; - query: string; -} - -async function fetchIdentityPage({ pageSize, pageToken, query }: FetchIdentityPageProps) { - 'use server'; - - const identityApi = await getIdentityApi(); - const response = await identityApi.listIdentities({ - pageSize: pageSize, - pageToken: pageToken, - previewCredentialsIdentifierSimilar: query, - }); - - return { - data: response.data, - tokens: parseTokens(response.headers.link), - }; -} - -function parseTokens(link: string) { - - const parsed = link.split(',').map((it) => { - const startRel = it.lastIndexOf('rel="'); - const endRel = it.lastIndexOf('"'); - const rel = it.slice(startRel, endRel); - - const startToken = it.lastIndexOf('page_token='); - const endToken = it.lastIndexOf('&'); - const token = it.slice(startToken, endToken); - - return [rel, token]; - }); - - return new Map(parsed.map(obj => [ - obj[0].replace('rel="', ''), - obj[1].replace('page_token=', ''), - ])); -} +import { queryIdentities } from '@/lib/action/identity'; +import { IdentityPagination } from '@/components/pagination'; export default async function UserPage( { @@ -54,12 +13,14 @@ export default async function UserPage( ) { const params = await searchParams; + + const page = params.page ? Number(params.page) : 1; const query = params.query ? params.query as string : ''; - let pageSize = 250; - let pageToken: string = '00000000-0000-0000-0000-000000000000'; + let pageSize = 50; + let paginationRange = 11; - const initialFetch = await fetchIdentityPage({ pageSize, pageToken, query: query }); + const { data, itemCount, pageCount } = await queryIdentities({ page, pageSize, query }); return (
@@ -70,13 +31,23 @@ export default async function UserPage(

- - + +
+

{itemCount} item{itemCount && itemCount > 1 ? 's' : ''} found

+ +
+
); diff --git a/dashboard/src/components/pagination.tsx b/dashboard/src/components/pagination.tsx new file mode 100644 index 0000000..6e16bc2 --- /dev/null +++ b/dashboard/src/components/pagination.tsx @@ -0,0 +1,101 @@ +'use client'; + +import { + Pagination, + PaginationContent, + PaginationEllipsis, + PaginationItem, + PaginationLink, + PaginationNext, + PaginationPrevious, +} from '@/components/ui/pagination'; +import { usePathname, useSearchParams } from 'next/navigation'; + +interface IdentityPaginationProps { + page: number; + pageCount: number; + pageParamKey: string; + paginationRange: number; +} + +export function IdentityPagination( + { + page, + pageCount, + pageParamKey, + paginationRange, + }: IdentityPaginationProps, +) { + + const pathname = usePathname(); + const searchParams = useSearchParams(); + + function updatePage(page: number): string { + const newParams = new URLSearchParams(searchParams.toString()); + + if (page <= 1) { + newParams.delete(pageParamKey); + } else { + newParams.set(pageParamKey, page.toString()); + } + + return pathname + '?' + newParams.toString(); + } + + return ( + + + { + page > 1 && ( + + + + ) + } + { + page - (paginationRange / 2) > 1 && + + + + } + { + Array.from({ length: paginationRange }, (_, i) => { + + const difference = (i + 1) - Math.round(paginationRange / 2); + const nextPage = page + difference; + + if (nextPage < 1 || nextPage > pageCount) { + return; + } + + return ( + + + {nextPage} + + + ); + }) + } + { + page + (paginationRange / 2) < pageCount && + + + + } + { + page < pageCount && ( + + + + ) + } + + + ); +} \ No newline at end of file diff --git a/dashboard/src/components/search-input.tsx b/dashboard/src/components/search-input.tsx index fa6be17..50e2d6a 100644 --- a/dashboard/src/components/search-input.tsx +++ b/dashboard/src/components/search-input.tsx @@ -2,23 +2,26 @@ import { Input } from '@/components/ui/input'; import { useRouter, useSearchParams } from 'next/navigation'; -import { ChangeEvent, HTMLInputTypeAttribute } from 'react'; +import { HTMLInputTypeAttribute, useState } from 'react'; interface SearchInputProps { + value: string; placeholder: string; + pageParamKey: string; queryParamKey: string; type?: HTMLInputTypeAttribute; className?: string; } -export function SearchInput({ placeholder, queryParamKey, type, className }: SearchInputProps) { +export function SearchInput({ value, placeholder, pageParamKey, queryParamKey, type, className }: SearchInputProps) { const router = useRouter(); const params = useSearchParams(); - const onSearchChange = (event: ChangeEvent) => { + const [searchInput, setSearchInput] = useState(value); + + const onSearchChange = (value: string) => { - const value = event.target.value; const newParams = new URLSearchParams(params.toString()); if (value.length < 1) { @@ -27,14 +30,24 @@ export function SearchInput({ placeholder, queryParamKey, type, className }: Sea newParams.set(queryParamKey, value); } + newParams.delete(pageParamKey); + router.replace('?' + newParams.toString()); }; + const handleKeyDown = (event: React.KeyboardEvent) => { + if (event.key === 'Enter') { + onSearchChange(searchInput); + } + }; + return ( + onChange={(e) => setSearchInput(e.target.value)} + onKeyDown={handleKeyDown}/> ); } diff --git a/dashboard/src/components/ui/pagination.tsx b/dashboard/src/components/ui/pagination.tsx new file mode 100644 index 0000000..db9b2d6 --- /dev/null +++ b/dashboard/src/components/ui/pagination.tsx @@ -0,0 +1,117 @@ +import * as React from 'react'; +import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react'; + +import { cn } from '@/lib/utils'; +import { ButtonProps, buttonVariants } from '@/components/ui/button'; + +const Pagination = ({ className, ...props }: React.ComponentProps<'nav'>) => ( +