# Schema snapshot — generated by schema_snapshot test. # Do not edit by hand. Run with BLESS=1 to regenerate. ## tables table: abandoned_executions id: uuid NOT NULL default=gen_random_uuid() app_id: uuid NOT NULL outbox_id: uuid NOT NULL script_id: uuid NULL inbox_id: uuid NOT NULL status_code: integer NOT NULL result_summary: text NULL created_at: timestamp with time zone NOT NULL default=now() table: admin_sessions token_hash: text NOT NULL user_id: uuid NOT NULL created_at: timestamp with time zone NOT NULL default=now() expires_at: timestamp with time zone NOT NULL last_used_at: timestamp with time zone NOT NULL default=now() table: admin_users id: uuid NOT NULL default=gen_random_uuid() username: text NOT NULL password_hash: text NOT NULL is_active: boolean NOT NULL default=true created_at: timestamp with time zone NOT NULL default=now() updated_at: timestamp with time zone NOT NULL default=now() last_login_at: timestamp with time zone NULL instance_role: text NOT NULL default='owner'::text email: text NULL mfa_secret: text NULL table: api_keys id: uuid NOT NULL default=gen_random_uuid() user_id: uuid NOT NULL hash: text NOT NULL prefix: text NOT NULL name: text NOT NULL scopes: ARRAY NOT NULL app_id: uuid NULL expires_at: timestamp with time zone NULL last_used_at: timestamp with time zone NULL created_at: timestamp with time zone NOT NULL default=now() table: app_domains id: uuid NOT NULL default=gen_random_uuid() app_id: uuid NOT NULL pattern: text NOT NULL shape: text NOT NULL shape_key: text NOT NULL created_at: timestamp with time zone NOT NULL default=now() table: app_members app_id: uuid NOT NULL user_id: uuid NOT NULL role: text NOT NULL created_at: timestamp with time zone NOT NULL default=now() table: app_secrets app_id: uuid NOT NULL realtime_signing_key: bytea NULL created_at: timestamp with time zone NOT NULL default=now() updated_at: timestamp with time zone NOT NULL default=now() realtime_signing_key_encrypted: bytea NULL realtime_signing_key_nonce: bytea NULL table: app_slug_history slug: text NOT NULL current_app_id: uuid NOT NULL retired_at: timestamp with time zone NOT NULL default=now() table: apps id: uuid NOT NULL default=gen_random_uuid() slug: text NOT NULL name: text NOT NULL description: text NULL created_at: timestamp with time zone NOT NULL default=now() updated_at: timestamp with time zone NOT NULL default=now() table: cron_trigger_details trigger_id: uuid NOT NULL schedule: text NOT NULL timezone: text NOT NULL default='UTC'::text last_fired_at: timestamp with time zone NULL table: dead_letter_trigger_details trigger_id: uuid NOT NULL source_filter: text NULL trigger_id_filter: uuid NULL script_id_filter: uuid NULL table: dead_letters id: uuid NOT NULL default=gen_random_uuid() app_id: uuid NOT NULL original_event_id: uuid NOT NULL source: text NOT NULL op: text NOT NULL trigger_id: uuid NULL script_id: uuid NULL payload: jsonb NOT NULL attempt_count: integer NOT NULL first_attempt_at: timestamp with time zone NOT NULL last_attempt_at: timestamp with time zone NOT NULL last_error: text NOT NULL created_at: timestamp with time zone NOT NULL default=now() resolved_at: timestamp with time zone NULL resolution: text NULL table: docs app_id: uuid NOT NULL collection: text NOT NULL id: uuid NOT NULL data: jsonb NOT NULL created_at: timestamp with time zone NOT NULL default=now() updated_at: timestamp with time zone NOT NULL default=now() table: docs_trigger_details trigger_id: uuid NOT NULL collection_glob: text NOT NULL ops: ARRAY NOT NULL table: email_trigger_details trigger_id: uuid NOT NULL inbound_secret_encrypted: bytea NULL inbound_secret_nonce: bytea NULL table: execution_logs id: uuid NOT NULL default=gen_random_uuid() script_id: uuid NOT NULL request_id: uuid NOT NULL request_path: text NULL request_headers: jsonb NOT NULL default='{}'::jsonb request_body: jsonb NULL response_code: integer NULL response_body: jsonb NULL logs: jsonb NOT NULL default='[]'::jsonb duration_ms: integer NOT NULL default=0 status: text NOT NULL created_at: timestamp with time zone NOT NULL default=now() app_id: uuid NOT NULL table: files app_id: uuid NOT NULL collection: text NOT NULL id: uuid NOT NULL name: text NOT NULL content_type: text NOT NULL size_bytes: bigint NOT NULL checksum_sha256: text NOT NULL created_at: timestamp with time zone NOT NULL default=now() updated_at: timestamp with time zone NOT NULL default=now() table: files_trigger_details trigger_id: uuid NOT NULL collection_glob: text NOT NULL ops: ARRAY NOT NULL table: kv_entries app_id: uuid NOT NULL collection: text NOT NULL key: text NOT NULL value: jsonb NOT NULL created_at: timestamp with time zone NOT NULL default=now() updated_at: timestamp with time zone NOT NULL default=now() table: kv_trigger_details trigger_id: uuid NOT NULL collection_glob: text NOT NULL ops: ARRAY NOT NULL table: outbox id: uuid NOT NULL default=gen_random_uuid() app_id: uuid NOT NULL source_kind: text NOT NULL trigger_id: uuid NULL script_id: uuid NULL reply_to: uuid NULL payload: jsonb NOT NULL origin_principal: uuid NULL trigger_depth: integer NOT NULL default=0 root_execution_id: uuid NULL attempt_count: integer NOT NULL default=0 next_attempt_at: timestamp with time zone NOT NULL default=now() claimed_at: timestamp with time zone NULL claimed_by: text NULL created_at: timestamp with time zone NOT NULL default=now() table: pubsub_trigger_details trigger_id: uuid NOT NULL topic_pattern: text NOT NULL table: routes id: uuid NOT NULL default=gen_random_uuid() script_id: uuid NOT NULL host_kind: text NOT NULL host: text NOT NULL default=''::text host_param_name: text NULL path_kind: text NOT NULL path: text NOT NULL method: text NULL created_at: timestamp with time zone NOT NULL default=now() app_id: uuid NOT NULL dispatch_mode: text NOT NULL default='sync'::text table: script_imports app_id: uuid NOT NULL importer_script_id: uuid NOT NULL imported_script_id: uuid NOT NULL created_at: timestamp with time zone NOT NULL default=now() table: scripts id: uuid NOT NULL default=gen_random_uuid() name: text NOT NULL description: text NULL version: integer NOT NULL default=1 source: text NOT NULL timeout_seconds: integer NOT NULL default=30 memory_limit_mb: integer NOT NULL default=256 created_at: timestamp with time zone NOT NULL default=now() updated_at: timestamp with time zone NOT NULL default=now() sandbox: jsonb NOT NULL default='{}'::jsonb app_id: uuid NOT NULL kind: text NOT NULL default='endpoint'::text table: secrets app_id: uuid NOT NULL name: text NOT NULL encrypted_value: bytea NOT NULL nonce: bytea NOT NULL created_at: timestamp with time zone NOT NULL default=now() updated_at: timestamp with time zone NOT NULL default=now() table: topics app_id: uuid NOT NULL name: text NOT NULL external_subscribable: boolean NOT NULL default=false auth_mode: text NOT NULL default='public'::text created_at: timestamp with time zone NOT NULL default=now() updated_at: timestamp with time zone NOT NULL default=now() table: triggers id: uuid NOT NULL default=gen_random_uuid() app_id: uuid NOT NULL script_id: uuid NOT NULL kind: text NOT NULL enabled: boolean NOT NULL default=true dispatch_mode: text NOT NULL default='async'::text retry_max_attempts: integer NOT NULL retry_backoff: text NOT NULL retry_base_ms: integer NOT NULL registered_by_principal: uuid NOT NULL created_at: timestamp with time zone NOT NULL default=now() updated_at: timestamp with time zone NOT NULL default=now() ## indexes indexes on abandoned_executions: abandoned_executions_pkey: public.abandoned_executions USING btree (id) idx_abandoned_executions_gc: public.abandoned_executions USING btree (created_at) indexes on admin_sessions: admin_sessions_expiry_idx: public.admin_sessions USING btree (expires_at) admin_sessions_pkey: public.admin_sessions USING btree (token_hash) admin_sessions_user_idx: public.admin_sessions USING btree (user_id) indexes on admin_users: admin_users_email_key: public.admin_users USING btree (email) admin_users_instance_role_idx: public.admin_users USING btree (instance_role) admin_users_pkey: public.admin_users USING btree (id) admin_users_username_key: public.admin_users USING btree (username) indexes on api_keys: api_keys_pkey: public.api_keys USING btree (id) api_keys_prefix_idx: public.api_keys USING btree (prefix) api_keys_user_id_idx: public.api_keys USING btree (user_id) indexes on app_domains: app_domains_app_id_idx: public.app_domains USING btree (app_id) app_domains_pkey: public.app_domains USING btree (id) app_domains_shape_key_key: public.app_domains USING btree (shape_key) indexes on app_members: app_members_pkey: public.app_members USING btree (app_id, user_id) app_members_user_id_idx: public.app_members USING btree (user_id) indexes on app_secrets: app_secrets_pkey: public.app_secrets USING btree (app_id) indexes on app_slug_history: app_slug_history_pkey: public.app_slug_history USING btree (slug) indexes on apps: apps_pkey: public.apps USING btree (id) apps_slug_key: public.apps USING btree (slug) indexes on cron_trigger_details: cron_trigger_details_pkey: public.cron_trigger_details USING btree (trigger_id) idx_cron_triggers_due: public.cron_trigger_details USING btree (last_fired_at) indexes on dead_letter_trigger_details: dead_letter_trigger_details_pkey: public.dead_letter_trigger_details USING btree (trigger_id) indexes on dead_letters: dead_letters_pkey: public.dead_letters USING btree (id) idx_dead_letters_app_unresolved: public.dead_letters USING btree (app_id) WHERE (resolved_at IS NULL) idx_dead_letters_gc: public.dead_letters USING btree (created_at) indexes on docs: docs_pkey: public.docs USING btree (app_id, collection, id) idx_docs_app_collection: public.docs USING btree (app_id, collection) idx_docs_data_gin: public.docs USING gin (data jsonb_path_ops) indexes on docs_trigger_details: docs_trigger_details_pkey: public.docs_trigger_details USING btree (trigger_id) indexes on email_trigger_details: email_trigger_details_pkey: public.email_trigger_details USING btree (trigger_id) indexes on execution_logs: execution_logs_app_id_created_at_idx: public.execution_logs USING btree (app_id, created_at DESC) execution_logs_pkey: public.execution_logs USING btree (id) execution_logs_script_id_created_at_idx: public.execution_logs USING btree (script_id, created_at DESC) indexes on files: files_pkey: public.files USING btree (app_id, collection, id) idx_files_app_collection: public.files USING btree (app_id, collection) indexes on files_trigger_details: files_trigger_details_pkey: public.files_trigger_details USING btree (trigger_id) indexes on kv_entries: idx_kv_entries_app_collection: public.kv_entries USING btree (app_id, collection) kv_entries_pkey: public.kv_entries USING btree (app_id, collection, key) indexes on kv_trigger_details: kv_trigger_details_pkey: public.kv_trigger_details USING btree (trigger_id) indexes on outbox: idx_outbox_app: public.outbox USING btree (app_id) idx_outbox_due: public.outbox USING btree (next_attempt_at) WHERE (claimed_at IS NULL) outbox_pkey: public.outbox USING btree (id) indexes on pubsub_trigger_details: pubsub_trigger_details_pkey: public.pubsub_trigger_details USING btree (trigger_id) indexes on routes: routes_app_id_idx: public.routes USING btree (app_id) routes_lookup_idx: public.routes USING btree (host_kind, host) routes_pkey: public.routes USING btree (id) routes_script_id_idx: public.routes USING btree (script_id) routes_unique_binding_idx: public.routes USING btree (app_id, host_kind, host, path_kind, path, COALESCE(method, ''::text)) indexes on script_imports: idx_script_imports_app: public.script_imports USING btree (app_id) idx_script_imports_imported: public.script_imports USING btree (imported_script_id) script_imports_pkey: public.script_imports USING btree (importer_script_id, imported_script_id) indexes on scripts: idx_scripts_app_kind: public.scripts USING btree (app_id, kind) scripts_app_id_idx: public.scripts USING btree (app_id) scripts_name_uidx: public.scripts USING btree (app_id, lower(name)) scripts_pkey: public.scripts USING btree (id) indexes on secrets: idx_secrets_app: public.secrets USING btree (app_id) secrets_pkey: public.secrets USING btree (app_id, name) indexes on topics: topics_pkey: public.topics USING btree (app_id, name) indexes on triggers: idx_triggers_app_kind_enabled: public.triggers USING btree (app_id, kind) WHERE (enabled = true) idx_triggers_app_pubsub_enabled: public.triggers USING btree (app_id, kind) WHERE ((enabled = true) AND (kind = 'pubsub'::text)) triggers_pkey: public.triggers USING btree (id) ## constraints constraints on abandoned_executions: [FOREIGN KEY] abandoned_executions_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] abandoned_executions_pkey: PRIMARY KEY (id) constraints on admin_sessions: [FOREIGN KEY] admin_sessions_user_id_fkey: FOREIGN KEY (user_id) REFERENCES admin_users(id) ON DELETE CASCADE [PRIMARY KEY] admin_sessions_pkey: PRIMARY KEY (token_hash) constraints on admin_users: [CHECK] admin_users_instance_role_check: CHECK ((instance_role = ANY (ARRAY['owner'::text, 'admin'::text, 'member'::text]))) [PRIMARY KEY] admin_users_pkey: PRIMARY KEY (id) [UNIQUE] admin_users_email_key: UNIQUE (email) [UNIQUE] admin_users_username_key: UNIQUE (username) constraints on api_keys: [FOREIGN KEY] api_keys_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [FOREIGN KEY] api_keys_user_id_fkey: FOREIGN KEY (user_id) REFERENCES admin_users(id) ON DELETE CASCADE [PRIMARY KEY] api_keys_pkey: PRIMARY KEY (id) constraints on app_domains: [CHECK] app_domains_shape_check: CHECK ((shape = ANY (ARRAY['exact'::text, 'wildcard'::text, 'parameterized'::text]))) [FOREIGN KEY] app_domains_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] app_domains_pkey: PRIMARY KEY (id) [UNIQUE] app_domains_shape_key_key: UNIQUE (shape_key) constraints on app_members: [CHECK] app_members_role_check: CHECK ((role = ANY (ARRAY['app_admin'::text, 'editor'::text, 'viewer'::text]))) [FOREIGN KEY] app_members_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [FOREIGN KEY] app_members_user_id_fkey: FOREIGN KEY (user_id) REFERENCES admin_users(id) ON DELETE CASCADE [PRIMARY KEY] app_members_pkey: PRIMARY KEY (app_id, user_id) constraints on app_secrets: [FOREIGN KEY] app_secrets_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] app_secrets_pkey: PRIMARY KEY (app_id) constraints on app_slug_history: [FOREIGN KEY] app_slug_history_current_app_id_fkey: FOREIGN KEY (current_app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] app_slug_history_pkey: PRIMARY KEY (slug) constraints on apps: [PRIMARY KEY] apps_pkey: PRIMARY KEY (id) [UNIQUE] apps_slug_key: UNIQUE (slug) constraints on cron_trigger_details: [FOREIGN KEY] cron_trigger_details_trigger_id_fkey: FOREIGN KEY (trigger_id) REFERENCES triggers(id) ON DELETE CASCADE [PRIMARY KEY] cron_trigger_details_pkey: PRIMARY KEY (trigger_id) constraints on dead_letter_trigger_details: [FOREIGN KEY] dead_letter_trigger_details_trigger_id_fkey: FOREIGN KEY (trigger_id) REFERENCES triggers(id) ON DELETE CASCADE [PRIMARY KEY] dead_letter_trigger_details_pkey: PRIMARY KEY (trigger_id) constraints on dead_letters: [CHECK] dead_letters_resolution_check: CHECK ((resolution = ANY (ARRAY['replayed'::text, 'ignored'::text, 'handled_by_script'::text, 'handler_failed'::text]))) [FOREIGN KEY] dead_letters_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] dead_letters_pkey: PRIMARY KEY (id) constraints on docs: [FOREIGN KEY] docs_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] docs_pkey: PRIMARY KEY (app_id, collection, id) constraints on docs_trigger_details: [FOREIGN KEY] docs_trigger_details_trigger_id_fkey: FOREIGN KEY (trigger_id) REFERENCES triggers(id) ON DELETE CASCADE [PRIMARY KEY] docs_trigger_details_pkey: PRIMARY KEY (trigger_id) constraints on email_trigger_details: [FOREIGN KEY] email_trigger_details_trigger_id_fkey: FOREIGN KEY (trigger_id) REFERENCES triggers(id) ON DELETE CASCADE [PRIMARY KEY] email_trigger_details_pkey: PRIMARY KEY (trigger_id) constraints on execution_logs: [CHECK] execution_logs_status_check: CHECK ((status = ANY (ARRAY['success'::text, 'error'::text, 'timeout'::text, 'budget_exceeded'::text]))) [FOREIGN KEY] execution_logs_app_id_fk: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [FOREIGN KEY] execution_logs_script_id_fkey: FOREIGN KEY (script_id) REFERENCES scripts(id) ON DELETE CASCADE [PRIMARY KEY] execution_logs_pkey: PRIMARY KEY (id) constraints on files: [FOREIGN KEY] files_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] files_pkey: PRIMARY KEY (app_id, collection, id) constraints on files_trigger_details: [FOREIGN KEY] files_trigger_details_trigger_id_fkey: FOREIGN KEY (trigger_id) REFERENCES triggers(id) ON DELETE CASCADE [PRIMARY KEY] files_trigger_details_pkey: PRIMARY KEY (trigger_id) constraints on kv_entries: [FOREIGN KEY] kv_entries_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] kv_entries_pkey: PRIMARY KEY (app_id, collection, key) constraints on kv_trigger_details: [FOREIGN KEY] kv_trigger_details_trigger_id_fkey: FOREIGN KEY (trigger_id) REFERENCES triggers(id) ON DELETE CASCADE [PRIMARY KEY] kv_trigger_details_pkey: PRIMARY KEY (trigger_id) constraints on outbox: [CHECK] outbox_source_kind_check: CHECK ((source_kind = ANY (ARRAY['http'::text, 'kv'::text, 'dead_letter'::text, 'docs'::text, 'cron'::text, 'files'::text, 'pubsub'::text, 'email'::text]))) [FOREIGN KEY] outbox_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] outbox_pkey: PRIMARY KEY (id) constraints on pubsub_trigger_details: [FOREIGN KEY] pubsub_trigger_details_trigger_id_fkey: FOREIGN KEY (trigger_id) REFERENCES triggers(id) ON DELETE CASCADE [PRIMARY KEY] pubsub_trigger_details_pkey: PRIMARY KEY (trigger_id) constraints on routes: [CHECK] routes_dispatch_mode_check: CHECK ((dispatch_mode = ANY (ARRAY['sync'::text, 'async'::text]))) [CHECK] routes_host_kind_check: CHECK ((host_kind = ANY (ARRAY['any'::text, 'strict'::text, 'wildcard'::text]))) [CHECK] routes_path_kind_check: CHECK ((path_kind = ANY (ARRAY['exact'::text, 'prefix'::text, 'param'::text]))) [FOREIGN KEY] routes_app_id_fk: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [FOREIGN KEY] routes_script_id_fkey: FOREIGN KEY (script_id) REFERENCES scripts(id) ON DELETE CASCADE [PRIMARY KEY] routes_pkey: PRIMARY KEY (id) constraints on script_imports: [FOREIGN KEY] script_imports_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [FOREIGN KEY] script_imports_imported_script_id_fkey: FOREIGN KEY (imported_script_id) REFERENCES scripts(id) ON DELETE CASCADE [FOREIGN KEY] script_imports_importer_script_id_fkey: FOREIGN KEY (importer_script_id) REFERENCES scripts(id) ON DELETE CASCADE [PRIMARY KEY] script_imports_pkey: PRIMARY KEY (importer_script_id, imported_script_id) constraints on scripts: [CHECK] scripts_kind_check: CHECK ((kind = ANY (ARRAY['endpoint'::text, 'module'::text]))) [CHECK] scripts_memory_limit_mb_check: CHECK (((memory_limit_mb > 0) AND (memory_limit_mb <= 2048))) [CHECK] scripts_module_name_shape: CHECK (((kind <> 'module'::text) OR (name ~ '^[a-zA-Z_][a-zA-Z0-9_]{0,63}$'::text))) [CHECK] scripts_timeout_seconds_check: CHECK (((timeout_seconds > 0) AND (timeout_seconds <= 300))) [FOREIGN KEY] scripts_app_id_fk: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE RESTRICT [PRIMARY KEY] scripts_pkey: PRIMARY KEY (id) constraints on secrets: [FOREIGN KEY] secrets_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] secrets_pkey: PRIMARY KEY (app_id, name) constraints on topics: [CHECK] topics_auth_mode_check: CHECK ((auth_mode = ANY (ARRAY['public'::text, 'token'::text]))) [FOREIGN KEY] topics_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [PRIMARY KEY] topics_pkey: PRIMARY KEY (app_id, name) constraints on triggers: [CHECK] triggers_dispatch_mode_check: CHECK ((dispatch_mode = ANY (ARRAY['sync'::text, 'async'::text]))) [CHECK] triggers_kind_check: CHECK ((kind = ANY (ARRAY['kv'::text, 'dead_letter'::text, 'docs'::text, 'cron'::text, 'files'::text, 'pubsub'::text, 'email'::text]))) [CHECK] triggers_retry_backoff_check: CHECK ((retry_backoff = ANY (ARRAY['exponential'::text, 'linear'::text, 'constant'::text]))) [FOREIGN KEY] triggers_app_id_fkey: FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE [FOREIGN KEY] triggers_registered_by_principal_fkey: FOREIGN KEY (registered_by_principal) REFERENCES admin_users(id) ON DELETE CASCADE [FOREIGN KEY] triggers_script_id_fkey: FOREIGN KEY (script_id) REFERENCES scripts(id) ON DELETE CASCADE [PRIMARY KEY] triggers_pkey: PRIMARY KEY (id) ## applied migrations 0001: init 0002: sandbox 0003: routes 0004: admin auth 0005: apps 0006: users authz 0007: kv 0008: triggers 0009: outbox 0010: dead letters 0011: abandoned executions 0012: routes dispatch mode 0013: docs 0014: docs triggers 0015: scripts kind 0016: script imports 0017: cron triggers 0018: files 0019: files triggers 0020: pubsub triggers 0021: topics 0022: app secrets 0023: secrets 0024: email triggers 0025: encrypt realtime keys