2023-05-21 17:59:36 +03:00
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
2026-07-07 09:14:15 +03:00
ActiveRecord :: Schema [ 8 . 1 ] . define ( version : 2026_07_07_055354 ) do
2023-05-21 17:59:36 +03:00
# These are extensions that must be enabled in order to support this database
2025-06-05 13:16:55 +03:00
enable_extension " btree_gin "
2026-04-01 19:07:57 +03:00
enable_extension " pg_catalog.plpgsql "
2023-05-21 17:59:36 +03:00
2023-08-06 17:33:08 +03:00
create_table " access_tokens " , force : :cascade do | t |
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . text " sha256 " , null : false
t . text " token " , null : false
2023-08-06 17:33:08 +03:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " user_id " , null : false
2023-08-06 17:33:08 +03:00
t . index [ " sha256 " ] , name : " index_access_tokens_on_sha256 " , unique : true
t . index [ " user_id " ] , name : " index_access_tokens_on_user_id "
end
2025-05-18 12:13:23 +03:00
create_table " account_accesses " , force : :cascade do | t |
t . bigint " account_id " , null : false
t . datetime " created_at " , null : false
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " user_id " , null : false
2025-05-18 12:13:23 +03:00
t . index [ " account_id " , " user_id " ] , name : " index_account_accesses_on_account_id_and_user_id " , unique : true
end
2023-08-16 22:57:59 +03:00
create_table " account_configs " , force : :cascade do | t |
t . bigint " account_id " , null : false
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " key " , null : false
2023-08-16 22:57:59 +03:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . text " value " , null : false
2023-08-16 22:57:59 +03:00
t . index [ " account_id " , " key " ] , name : " index_account_configs_on_account_id_and_key " , unique : true
t . index [ " account_id " ] , name : " index_account_configs_on_account_id "
end
2024-01-20 23:53:14 +02:00
create_table " account_linked_accounts " , force : :cascade do | t |
t . bigint " account_id " , null : false
t . text " account_type " , null : false
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " linked_account_id " , null : false
2024-01-20 23:53:14 +02:00
t . datetime " updated_at " , null : false
t . index [ " account_id " , " linked_account_id " ] , name : " idx_on_account_id_linked_account_id_48ab9f79d2 " , unique : true
t . index [ " account_id " ] , name : " index_account_linked_accounts_on_account_id "
t . index [ " linked_account_id " ] , name : " index_account_linked_accounts_on_linked_account_id "
end
2023-05-21 17:59:36 +03:00
create_table " accounts " , force : :cascade do | t |
2026-04-01 19:07:57 +03:00
t . datetime " archived_at "
t . datetime " created_at " , null : false
t . string " locale " , null : false
2023-05-21 17:59:36 +03:00
t . string " name " , null : false
2023-06-30 01:26:13 +03:00
t . string " timezone " , null : false
2023-05-21 17:59:36 +03:00
t . datetime " updated_at " , null : false
2024-04-05 19:55:35 +03:00
t . string " uuid " , null : false
t . index [ " uuid " ] , name : " index_accounts_on_uuid " , unique : true
2023-05-21 17:59:36 +03:00
end
create_table " active_storage_attachments " , force : :cascade do | t |
t . bigint " blob_id " , null : false
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " name " , null : false
t . bigint " record_id " , null : false
t . string " record_type " , null : false
t . string " uuid " , null : false
2023-05-21 17:59:36 +03:00
t . index [ " blob_id " ] , name : " index_active_storage_attachments_on_blob_id "
2024-08-16 15:20:56 +03:00
t . index [ " record_type " , " record_id " , " name " , " blob_id " ] , name : " idx_on_record_type_record_id_name_blob_id_0be5805727 "
2023-05-21 17:59:36 +03:00
t . index [ " uuid " ] , name : " index_active_storage_attachments_on_uuid "
end
create_table " active_storage_blobs " , force : :cascade do | t |
t . bigint " byte_size " , null : false
t . string " checksum "
2026-04-01 19:07:57 +03:00
t . string " content_type "
2023-05-21 17:59:36 +03:00
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " filename " , null : false
t . string " key " , null : false
t . text " metadata "
t . string " service_name " , null : false
2024-02-18 10:24:43 +02:00
t . string " uuid "
2024-02-28 10:35:51 +02:00
t . index [ " checksum " ] , name : " index_active_storage_blobs_on_checksum "
2023-05-21 17:59:36 +03:00
t . index [ " key " ] , name : " index_active_storage_blobs_on_key " , unique : true
2024-02-18 10:24:43 +02:00
t . index [ " uuid " ] , name : " index_active_storage_blobs_on_uuid " , unique : true
2023-05-21 17:59:36 +03:00
end
create_table " active_storage_variant_records " , force : :cascade do | t |
t . bigint " blob_id " , null : false
t . string " variation_digest " , null : false
t . index [ " blob_id " , " variation_digest " ] , name : " index_active_storage_variant_records_uniqueness " , unique : true
end
2024-10-22 22:29:24 +03:00
create_table " completed_documents " , force : :cascade do | t |
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " sha256 " , null : false
t . bigint " submitter_id " , null : false
2024-10-22 22:29:24 +03:00
t . datetime " updated_at " , null : false
t . index [ " sha256 " ] , name : " index_completed_documents_on_sha256 "
t . index [ " submitter_id " ] , name : " index_completed_documents_on_submitter_id "
end
create_table " completed_submitters " , force : :cascade do | t |
t . bigint " account_id " , null : false
t . datetime " completed_at " , null : false
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . boolean " is_first "
t . integer " sms_count " , null : false
t . string " source " , null : false
t . bigint " submission_id " , null : false
t . bigint " submitter_id " , null : false
t . bigint " template_id "
2024-10-22 22:29:24 +03:00
t . datetime " updated_at " , null : false
2025-09-01 14:09:00 +03:00
t . string " verification_method "
2025-11-21 11:45:19 +02:00
t . index [ " account_id " , " completed_at " ] , name : " index_completed_submitters_account_id_completed_at_is_first " , where : " (is_first = true) "
t . index [ " account_id " , " completed_at " ] , name : " index_completed_submitters_on_account_id_and_completed_at "
2025-11-21 11:27:28 +02:00
t . index [ " submission_id " ] , name : " index_completed_submitters_on_submission_id " , unique : true , where : " (is_first = true) "
2024-10-26 19:42:16 +03:00
t . index [ " submitter_id " ] , name : " index_completed_submitters_on_submitter_id " , unique : true
2024-10-22 22:29:24 +03:00
end
2025-02-25 13:16:11 +02:00
create_table " console1984_commands " , force : :cascade do | t |
2026-04-01 19:07:57 +03:00
t . datetime " created_at " , null : false
2025-02-25 13:16:11 +02:00
t . bigint " sensitive_access_id "
t . bigint " session_id " , null : false
2026-04-01 19:07:57 +03:00
t . text " statements "
2025-02-25 13:16:11 +02:00
t . datetime " updated_at " , null : false
t . index [ " sensitive_access_id " ] , name : " index_console1984_commands_on_sensitive_access_id "
t . index [ " session_id " , " created_at " , " sensitive_access_id " ] , name : " on_session_and_sensitive_chronologically "
end
create_table " console1984_sensitive_accesses " , force : :cascade do | t |
2026-04-01 19:07:57 +03:00
t . datetime " created_at " , null : false
2025-02-25 13:16:11 +02:00
t . text " justification "
t . bigint " session_id " , null : false
t . datetime " updated_at " , null : false
t . index [ " session_id " ] , name : " index_console1984_sensitive_accesses_on_session_id "
end
create_table " console1984_sessions " , force : :cascade do | t |
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . text " reason "
2025-02-25 13:16:11 +02:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " user_id " , null : false
2025-02-25 13:16:11 +02:00
t . index [ " created_at " ] , name : " index_console1984_sessions_on_created_at "
t . index [ " user_id " , " created_at " ] , name : " index_console1984_sessions_on_user_id_and_created_at "
end
create_table " console1984_users " , force : :cascade do | t |
t . datetime " created_at " , null : false
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " username " , null : false
2025-02-25 13:16:11 +02:00
t . index [ " username " ] , name : " index_console1984_users_on_username "
end
2023-07-01 13:16:07 +03:00
create_table " document_generation_events " , force : :cascade do | t |
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " event_name " , null : false
t . bigint " submitter_id " , null : false
2023-07-01 13:16:07 +03:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . index [ " submitter_id " , " event_name " ] , name : " index_document_generation_events_on_submitter_id_and_event_name " , unique : true , where : " ((event_name)::text = ANY (ARRAY[('start'::character varying)::text, ('complete'::character varying)::text])) "
2023-07-01 13:16:07 +03:00
t . index [ " submitter_id " ] , name : " index_document_generation_events_on_submitter_id "
end
2026-04-17 14:49:14 +03:00
create_table " document_metadata " , force : :cascade do | t |
t . bigint " account_id " , null : false
t . string " blob_checksum " , null : false
t . datetime " created_at " , null : false
t . text " text_runs " , null : false
t . index [ " account_id " , " blob_checksum " ] , name : " index_document_metadata_on_account_id_and_blob_checksum " , unique : true
end
2026-02-12 09:22:08 +02:00
create_table " dynamic_document_versions " , force : :cascade do | t |
t . text " areas " , null : false
t . datetime " created_at " , null : false
t . bigint " dynamic_document_id " , null : false
t . string " sha1 " , null : false
t . datetime " updated_at " , null : false
t . index [ " dynamic_document_id " , " sha1 " ] , name : " idx_on_dynamic_document_id_sha1_3503adf557 " , unique : true
end
create_table " dynamic_documents " , force : :cascade do | t |
t . text " body " , null : false
t . datetime " created_at " , null : false
t . text " head "
2026-03-09 09:00:09 +02:00
t . string " sha1 " , null : false
2026-02-12 09:22:08 +02:00
t . bigint " template_id " , null : false
t . datetime " updated_at " , null : false
2026-03-09 09:00:09 +02:00
t . string " uuid " , null : false
2026-02-12 09:22:08 +02:00
t . index [ " template_id " ] , name : " index_dynamic_documents_on_template_id "
end
2024-06-04 11:48:02 +03:00
create_table " email_events " , force : :cascade do | t |
t . bigint " account_id " , null : false
2026-04-01 19:07:57 +03:00
t . datetime " created_at " , null : false
t . text " data " , null : false
t . string " email " , null : false
2024-06-04 11:48:02 +03:00
t . bigint " emailable_id " , null : false
2026-04-01 19:07:57 +03:00
t . string " emailable_type " , null : false
t . datetime " event_datetime " , null : false
t . string " event_type " , null : false
2024-06-04 11:48:02 +03:00
t . string " message_id " , null : false
t . string " tag " , null : false
2025-05-30 11:12:33 +03:00
t . index [ " account_id " , " event_datetime " ] , name : " index_email_events_on_account_id_and_event_datetime "
2024-07-20 09:40:57 +03:00
t . index [ " email " ] , name : " index_email_events_on_email "
2026-04-01 19:07:57 +03:00
t . index [ " email " ] , name : " index_email_events_on_email_event_types " , where : " ((event_type)::text = ANY (ARRAY[('bounce'::character varying)::text, ('soft_bounce'::character varying)::text, ('permanent_bounce'::character varying)::text, ('complaint'::character varying)::text, ('soft_complaint'::character varying)::text])) "
2024-06-04 11:48:02 +03:00
t . index [ " emailable_type " , " emailable_id " ] , name : " index_email_events_on_emailable "
t . index [ " message_id " ] , name : " index_email_events_on_message_id "
end
2026-06-29 12:30:10 +03:00
create_table " email_message_assets " , force : :cascade do | t |
t . bigint " account_id " , null : false
t . datetime " created_at " , null : false
t . text " data " , null : false
t . string " sha1 " , null : false
t . datetime " updated_at " , null : false
t . index [ " account_id " , " sha1 " ] , name : " index_email_message_assets_on_account_id_and_sha1 " , unique : true
end
2023-11-23 20:03:52 +02:00
create_table " email_messages " , force : :cascade do | t |
t . bigint " account_id " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " author_id " , null : false
2023-11-23 20:03:52 +02:00
t . text " body " , null : false
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " sha1 " , null : false
t . text " subject " , null : false
2023-11-23 20:03:52 +02:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " uuid " , null : false
2023-11-23 20:03:52 +02:00
t . index [ " account_id " ] , name : " index_email_messages_on_account_id "
t . index [ " sha1 " ] , name : " index_email_messages_on_sha1 "
t . index [ " uuid " ] , name : " index_email_messages_on_uuid "
end
2023-05-21 17:59:36 +03:00
create_table " encrypted_configs " , force : :cascade do | t |
t . bigint " account_id " , null : false
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " key " , null : false
2023-05-21 17:59:36 +03:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . text " value " , null : false
2023-05-21 17:59:36 +03:00
t . index [ " account_id " , " key " ] , name : " index_encrypted_configs_on_account_id_and_key " , unique : true
t . index [ " account_id " ] , name : " index_encrypted_configs_on_account_id "
end
2023-09-25 01:57:10 +03:00
create_table " encrypted_user_configs " , force : :cascade do | t |
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " key " , null : false
2023-09-25 01:57:10 +03:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " user_id " , null : false
t . text " value " , null : false
2023-09-25 01:57:10 +03:00
t . index [ " user_id " , " key " ] , name : " index_encrypted_user_configs_on_user_id_and_key " , unique : true
t . index [ " user_id " ] , name : " index_encrypted_user_configs_on_user_id "
end
2025-09-15 09:10:03 +03:00
create_table " lock_events " , force : :cascade do | t |
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " event_name " , null : false
t . string " key " , null : false
2025-09-15 09:10:03 +03:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . index [ " event_name " , " key " ] , name : " index_lock_events_on_event_name_and_key " , unique : true , where : " ((event_name)::text = ANY (ARRAY[('start'::character varying)::text, ('complete'::character varying)::text])) "
2025-09-15 09:10:03 +03:00
t . index [ " key " ] , name : " index_lock_events_on_key "
end
2026-03-05 12:17:14 +02:00
create_table " mcp_tokens " , force : :cascade do | t |
t . datetime " archived_at "
t . datetime " created_at " , null : false
t . string " name " , null : false
t . string " sha256 " , null : false
t . string " token_prefix " , null : false
t . datetime " updated_at " , null : false
t . bigint " user_id " , null : false
t . index [ " sha256 " ] , name : " index_mcp_tokens_on_sha256 " , unique : true
t . index [ " user_id " ] , name : " index_mcp_tokens_on_user_id "
end
2024-07-13 19:26:37 +03:00
create_table " oauth_access_grants " , force : :cascade do | t |
t . bigint " application_id " , null : false
2026-04-01 19:07:57 +03:00
t . string " code_challenge "
t . string " code_challenge_method "
t . datetime " created_at " , null : false
2024-07-13 19:26:37 +03:00
t . integer " expires_in " , null : false
t . text " redirect_uri " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " resource_owner_id " , null : false
2024-07-13 19:26:37 +03:00
t . datetime " revoked_at "
2026-04-01 19:07:57 +03:00
t . string " scopes " , default : " " , null : false
t . string " token " , null : false
2024-07-13 19:26:37 +03:00
t . index [ " application_id " ] , name : " index_oauth_access_grants_on_application_id "
t . index [ " resource_owner_id " ] , name : " index_oauth_access_grants_on_resource_owner_id "
t . index [ " token " ] , name : " index_oauth_access_grants_on_token " , unique : true
end
create_table " oauth_access_tokens " , force : :cascade do | t |
t . bigint " application_id " , null : false
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . integer " expires_in "
2024-07-13 19:26:37 +03:00
t . string " previous_refresh_token " , default : " " , null : false
2026-04-01 19:07:57 +03:00
t . string " refresh_token "
t . bigint " resource_owner_id "
t . datetime " revoked_at "
t . string " scopes "
t . string " token " , null : false
2024-07-13 19:26:37 +03:00
t . index [ " application_id " ] , name : " index_oauth_access_tokens_on_application_id "
t . index [ " refresh_token " ] , name : " index_oauth_access_tokens_on_refresh_token " , unique : true
t . index [ " resource_owner_id " ] , name : " index_oauth_access_tokens_on_resource_owner_id "
t . index [ " token " ] , name : " index_oauth_access_tokens_on_token " , unique : true
end
create_table " oauth_applications " , force : :cascade do | t |
2026-04-01 19:07:57 +03:00
t . boolean " confidential " , default : true , null : false
t . datetime " created_at " , null : false
2024-07-13 19:26:37 +03:00
t . string " name " , null : false
t . text " redirect_uri "
t . string " scopes " , default : " " , null : false
2026-04-01 19:07:57 +03:00
t . string " secret " , null : false
t . string " uid " , null : false
2024-07-13 19:26:37 +03:00
t . datetime " updated_at " , null : false
t . index [ " uid " ] , name : " index_oauth_applications_on_uid " , unique : true
end
2025-06-05 13:16:55 +03:00
create_table " search_entries " , force : :cascade do | t |
t . bigint " account_id " , null : false
t . datetime " created_at " , null : false
2025-06-09 09:55:30 +03:00
t . tsvector " ngram "
2026-04-01 19:07:57 +03:00
t . bigint " record_id " , null : false
t . string " record_type " , null : false
t . tsvector " tsvector " , null : false
t . datetime " updated_at " , null : false
2025-06-09 09:55:30 +03:00
t . index [ " account_id " , " ngram " ] , name : " index_search_entries_on_account_id_ngram_submission " , where : " ((record_type)::text = 'Submission'::text) " , using : :gin
t . index [ " account_id " , " ngram " ] , name : " index_search_entries_on_account_id_ngram_submitter " , where : " ((record_type)::text = 'Submitter'::text) " , using : :gin
t . index [ " account_id " , " ngram " ] , name : " index_search_entries_on_account_id_ngram_template " , where : " ((record_type)::text = 'Template'::text) " , using : :gin
2025-06-05 13:16:55 +03:00
t . index [ " account_id " , " tsvector " ] , name : " index_search_entries_on_account_id_tsvector_submission " , where : " ((record_type)::text = 'Submission'::text) " , using : :gin
t . index [ " account_id " , " tsvector " ] , name : " index_search_entries_on_account_id_tsvector_submitter " , where : " ((record_type)::text = 'Submitter'::text) " , using : :gin
t . index [ " account_id " , " tsvector " ] , name : " index_search_entries_on_account_id_tsvector_template " , where : " ((record_type)::text = 'Template'::text) " , using : :gin
t . index [ " record_id " , " record_type " ] , name : " index_search_entries_on_record_id_and_record_type " , unique : true
end
2023-09-10 12:55:41 +03:00
create_table " submission_events " , force : :cascade do | t |
2026-04-01 19:07:57 +03:00
t . bigint " account_id "
t . datetime " created_at " , null : false
2023-09-10 12:55:41 +03:00
t . text " data " , null : false
t . datetime " event_timestamp " , null : false
2026-04-01 19:07:57 +03:00
t . string " event_type " , null : false
t . bigint " submission_id " , null : false
t . bigint " submitter_id "
2023-09-10 12:55:41 +03:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . index [ " account_id " , " created_at " ] , name : " index_submissions_events_on_sms_event_types " , where : " ((event_type)::text = ANY (ARRAY[('send_sms'::character varying)::text, ('send_2fa_sms'::character varying)::text])) "
2025-11-21 11:17:20 +02:00
t . index [ " account_id " ] , name : " index_submission_events_on_account_id "
2024-02-28 09:49:59 +02:00
t . index [ " created_at " ] , name : " index_submission_events_on_created_at "
2023-09-10 12:55:41 +03:00
t . index [ " submission_id " ] , name : " index_submission_events_on_submission_id "
t . index [ " submitter_id " ] , name : " index_submission_events_on_submitter_id "
end
2023-05-21 17:59:36 +03:00
create_table " submissions " , force : :cascade do | t |
2026-04-01 19:07:57 +03:00
t . bigint " account_id " , null : false
2023-12-30 00:37:03 +02:00
t . datetime " archived_at "
2026-07-01 18:10:08 +03:00
t . datetime " completed_at "
2023-06-13 00:29:07 +03:00
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " created_by_user_id "
t . datetime " expire_at "
t . text " name "
t . text " preferences " , null : false
t . string " slug " , null : false
t . string " source " , null : false
t . string " submitters_order " , null : false
2023-07-26 09:58:50 +03:00
t . text " template_fields "
2026-04-01 19:07:57 +03:00
t . bigint " template_id "
2023-07-26 09:58:50 +03:00
t . text " template_schema "
t . text " template_submitters "
2026-04-01 19:07:57 +03:00
t . datetime " updated_at " , null : false
2025-09-12 12:17:26 +03:00
t . text " variables "
2026-04-01 19:07:57 +03:00
t . text " variables_schema "
2026-07-01 21:50:02 +03:00
t . index [ " account_id " , " completed_at " ] , name : " index_submissions_on_account_id_and_completed_at " , where : " ((completed_at IS NOT NULL) AND (archived_at IS NULL)) "
2024-08-16 11:39:34 +03:00
t . index [ " account_id " , " id " ] , name : " index_submissions_on_account_id_and_id "
2026-07-01 21:50:02 +03:00
t . index [ " account_id " , " id " ] , name : " index_submissions_on_account_id_and_id_pending " , where : " ((completed_at IS NULL) AND (archived_at IS NULL)) "
2025-06-17 10:37:25 +03:00
t . index [ " account_id " , " template_id " , " id " ] , name : " index_submissions_on_account_id_and_template_id_and_id " , where : " (archived_at IS NULL) "
2025-06-18 11:42:23 +03:00
t . index [ " account_id " , " template_id " , " id " ] , name : " index_submissions_on_account_id_and_template_id_and_id_archived " , where : " (archived_at IS NOT NULL) "
2026-07-07 09:14:15 +03:00
t . index [ " created_at " ] , name : " index_submissions_on_created_at "
2023-06-29 02:04:17 +03:00
t . index [ " created_by_user_id " ] , name : " index_submissions_on_created_by_user_id "
2023-11-20 00:52:05 +02:00
t . index [ " slug " ] , name : " index_submissions_on_slug " , unique : true
2023-06-13 00:29:07 +03:00
t . index [ " template_id " ] , name : " index_submissions_on_template_id "
end
2026-03-27 12:56:52 +02:00
create_table " submitter_versions " , force : :cascade do | t |
t . datetime " created_at " , null : false
t . string " email "
t . string " name "
t . string " phone "
t . string " slug " , null : false
t . bigint " submitter_id " , null : false
t . datetime " updated_at " , null : false
t . index [ " slug " ] , name : " index_submitter_versions_on_slug "
t . index [ " submitter_id " ] , name : " index_submitter_versions_on_submitter_id "
end
2023-06-13 00:29:07 +03:00
create_table " submitters " , force : :cascade do | t |
2026-04-01 19:07:57 +03:00
t . bigint " account_id " , null : false
2023-05-21 17:59:36 +03:00
t . datetime " completed_at "
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . datetime " declined_at "
t . string " email "
t . string " external_id "
t . string " ip "
t . text " metadata " , null : false
2023-09-03 14:05:31 +03:00
t . string " name "
2026-04-01 19:07:57 +03:00
t . datetime " opened_at "
2023-09-03 14:05:31 +03:00
t . string " phone "
2023-11-23 20:03:52 +02:00
t . text " preferences " , null : false
2026-04-01 19:07:57 +03:00
t . datetime " sent_at "
t . string " slug " , null : false
t . bigint " submission_id " , null : false
2025-06-13 19:12:35 +03:00
t . string " timezone "
2026-04-01 19:07:57 +03:00
t . string " ua "
t . datetime " updated_at " , null : false
t . string " uuid " , null : false
t . text " values " , null : false
2026-06-27 11:40:02 +03:00
t . index [ " account_id " , " completed_at " ] , name : " index_submitters_on_account_id_and_completed_at " , where : " (completed_at IS NOT NULL) "
2024-08-16 10:19:00 +03:00
t . index [ " account_id " , " id " ] , name : " index_submitters_on_account_id_and_id "
2023-06-13 00:29:07 +03:00
t . index [ " email " ] , name : " index_submitters_on_email "
2024-06-24 13:27:14 +03:00
t . index [ " external_id " ] , name : " index_submitters_on_external_id "
2023-06-13 00:29:07 +03:00
t . index [ " slug " ] , name : " index_submitters_on_slug " , unique : true
t . index [ " submission_id " ] , name : " index_submitters_on_submission_id "
2023-05-31 23:19:20 +03:00
end
2024-12-08 01:37:20 +02:00
create_table " template_accesses " , force : :cascade do | t |
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " template_id " , null : false
2024-12-08 01:37:20 +02:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " user_id " , null : false
2024-12-08 01:37:20 +02:00
t . index [ " template_id " , " user_id " ] , name : " index_template_accesses_on_template_id_and_user_id " , unique : true
end
2023-09-21 00:23:38 +03:00
create_table " template_folders " , force : :cascade do | t |
t . bigint " account_id " , null : false
2023-12-30 00:37:03 +02:00
t . datetime " archived_at "
2026-04-01 19:07:57 +03:00
t . bigint " author_id " , null : false
2023-09-21 00:23:38 +03:00
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " name " , null : false
2025-07-20 08:28:19 +03:00
t . bigint " parent_folder_id "
2026-04-01 19:07:57 +03:00
t . datetime " updated_at " , null : false
2023-09-21 00:23:38 +03:00
t . index [ " account_id " ] , name : " index_template_folders_on_account_id "
t . index [ " author_id " ] , name : " index_template_folders_on_author_id "
2025-07-20 08:28:19 +03:00
t . index [ " parent_folder_id " ] , name : " index_template_folders_on_parent_folder_id "
2023-09-21 00:23:38 +03:00
end
2024-02-03 22:37:17 +02:00
create_table " template_sharings " , force : :cascade do | t |
t . string " ability " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " account_id " , null : false
2024-02-03 22:37:17 +02:00
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " template_id " , null : false
2024-02-03 22:37:17 +02:00
t . datetime " updated_at " , null : false
t . index [ " account_id " , " template_id " ] , name : " index_template_sharings_on_account_id_and_template_id " , unique : true
t . index [ " template_id " ] , name : " index_template_sharings_on_template_id "
end
2026-05-07 09:48:25 +03:00
create_table " template_versions " , force : :cascade do | t |
t . bigint " account_id " , null : false
t . bigint " author_id " , null : false
t . datetime " created_at " , null : false
t . text " data " , null : false
t . string " sha1 " , null : false
t . bigint " template_id " , null : false
t . datetime " updated_at " , null : false
t . index [ " account_id " ] , name : " index_template_versions_on_account_id "
t . index [ " author_id " ] , name : " index_template_versions_on_author_id "
t . index [ " template_id " , " sha1 " ] , name : " index_template_versions_on_template_id_and_sha1 " , unique : true
end
2023-05-31 23:19:20 +03:00
create_table " templates " , force : :cascade do | t |
t . bigint " account_id " , null : false
2023-12-30 00:37:03 +02:00
t . datetime " archived_at "
2026-04-01 19:07:57 +03:00
t . bigint " author_id " , null : false
2023-05-31 23:19:20 +03:00
t . datetime " created_at " , null : false
2024-02-01 00:34:35 +02:00
t . string " external_id "
2026-04-01 19:07:57 +03:00
t . text " fields " , null : false
t . bigint " folder_id " , null : false
t . string " name " , null : false
2024-04-17 16:08:58 +03:00
t . text " preferences " , null : false
2026-04-01 19:07:57 +03:00
t . text " schema " , null : false
2025-05-26 13:32:32 +03:00
t . boolean " shared_link " , default : false , null : false
2026-04-01 19:07:57 +03:00
t . string " slug " , null : false
t . text " source " , null : false
t . text " submitters " , null : false
t . datetime " updated_at " , null : false
2025-09-12 12:17:26 +03:00
t . text " variables_schema "
2025-06-17 10:37:25 +03:00
t . index [ " account_id " , " folder_id " , " id " ] , name : " index_templates_on_account_id_and_folder_id_and_id " , where : " (archived_at IS NULL) "
2025-06-18 11:42:23 +03:00
t . index [ " account_id " , " id " ] , name : " index_templates_on_account_id_and_id_archived " , where : " (archived_at IS NOT NULL) "
2023-05-31 23:19:20 +03:00
t . index [ " account_id " ] , name : " index_templates_on_account_id "
t . index [ " author_id " ] , name : " index_templates_on_author_id "
2024-06-24 13:27:14 +03:00
t . index [ " external_id " ] , name : " index_templates_on_external_id "
2023-09-21 00:23:38 +03:00
t . index [ " folder_id " ] , name : " index_templates_on_folder_id "
2023-05-31 23:19:20 +03:00
t . index [ " slug " ] , name : " index_templates_on_slug " , unique : true
2023-05-21 17:59:36 +03:00
end
2023-09-22 21:50:39 +03:00
create_table " user_configs " , force : :cascade do | t |
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " key " , null : false
2023-09-22 21:50:39 +03:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " user_id " , null : false
t . text " value " , null : false
2023-09-22 21:50:39 +03:00
t . index [ " user_id " , " key " ] , name : " index_user_configs_on_user_id_and_key " , unique : true
t . index [ " user_id " ] , name : " index_user_configs_on_user_id "
end
2023-05-21 17:59:36 +03:00
create_table " users " , force : :cascade do | t |
t . bigint " account_id " , null : false
2026-04-01 19:07:57 +03:00
t . datetime " archived_at "
t . datetime " confirmation_sent_at "
t . string " confirmation_token "
t . datetime " confirmed_at "
t . integer " consumed_timestep "
t . datetime " created_at " , null : false
2023-05-21 17:59:36 +03:00
t . datetime " current_sign_in_at "
t . string " current_sign_in_ip "
2026-04-01 19:07:57 +03:00
t . string " email " , null : false
t . string " encrypted_password " , null : false
2023-05-21 17:59:36 +03:00
t . integer " failed_attempts " , default : 0 , null : false
2026-04-01 19:07:57 +03:00
t . string " first_name "
t . string " last_name "
t . datetime " last_sign_in_at "
t . string " last_sign_in_ip "
2023-05-21 17:59:36 +03:00
t . datetime " locked_at "
2023-09-16 01:06:29 +03:00
t . boolean " otp_required_for_login " , default : false , null : false
2026-04-01 19:07:57 +03:00
t . string " otp_secret "
t . datetime " remember_created_at "
t . datetime " reset_password_sent_at "
t . string " reset_password_token "
t . string " role " , null : false
t . integer " sign_in_count " , default : 0 , null : false
2025-11-26 14:12:08 +02:00
t . string " unconfirmed_email "
2026-04-01 19:07:57 +03:00
t . string " unlock_token "
t . datetime " updated_at " , null : false
t . string " uuid " , null : false
2023-05-21 17:59:36 +03:00
t . index [ " account_id " ] , name : " index_users_on_account_id "
t . index [ " email " ] , name : " index_users_on_email " , unique : true
t . index [ " reset_password_token " ] , name : " index_users_on_reset_password_token " , unique : true
t . index [ " unlock_token " ] , name : " index_users_on_unlock_token " , unique : true
2023-08-04 00:40:13 +03:00
t . index [ " uuid " ] , name : " index_users_on_uuid " , unique : true
2023-05-21 17:59:36 +03:00
end
2025-07-04 21:11:08 +03:00
create_table " webhook_attempts " , force : :cascade do | t |
t . integer " attempt " , null : false
t . datetime " created_at " , null : false
2026-04-01 19:07:57 +03:00
t . text " response_body "
t . integer " response_status_code " , null : false
2025-07-04 21:11:08 +03:00
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . bigint " webhook_event_id " , null : false
2025-07-04 21:11:08 +03:00
t . index [ " webhook_event_id " ] , name : " index_webhook_attempts_on_webhook_event_id "
end
create_table " webhook_events " , force : :cascade do | t |
t . bigint " account_id " , null : false
2026-04-01 19:07:57 +03:00
t . datetime " created_at " , null : false
t . string " event_type " , null : false
2025-07-04 21:11:08 +03:00
t . bigint " record_id " , null : false
t . string " record_type " , null : false
t . string " status " , null : false
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . string " uuid " , null : false
t . bigint " webhook_url_id " , null : false
2025-07-04 21:11:08 +03:00
t . index [ " uuid " , " webhook_url_id " ] , name : " index_webhook_events_on_uuid_and_webhook_url_id " , unique : true
t . index [ " webhook_url_id " , " id " ] , name : " index_webhook_events_error " , where : " ((status)::text = 'error'::text) "
t . index [ " webhook_url_id " , " id " ] , name : " index_webhook_events_on_webhook_url_id_and_id "
end
2024-07-14 21:38:24 +03:00
create_table " webhook_urls " , force : :cascade do | t |
t . bigint " account_id " , null : false
2026-04-01 19:07:57 +03:00
t . datetime " created_at " , null : false
2024-07-14 21:38:24 +03:00
t . text " events " , null : false
2026-05-06 11:45:35 +03:00
t . text " hmac_secret " , null : false
2026-04-01 19:07:57 +03:00
t . text " secret " , null : false
2024-07-14 21:38:24 +03:00
t . string " sha1 " , null : false
t . datetime " updated_at " , null : false
2026-04-01 19:07:57 +03:00
t . text " url " , null : false
2024-07-14 21:38:24 +03:00
t . index [ " account_id " ] , name : " index_webhook_urls_on_account_id "
t . index [ " sha1 " ] , name : " index_webhook_urls_on_sha1 "
end
2023-08-06 17:33:08 +03:00
add_foreign_key " access_tokens " , " users "
2025-05-18 12:13:23 +03:00
add_foreign_key " account_accesses " , " accounts "
2023-08-16 22:57:59 +03:00
add_foreign_key " account_configs " , " accounts "
2024-01-20 23:53:14 +02:00
add_foreign_key " account_linked_accounts " , " accounts "
add_foreign_key " account_linked_accounts " , " accounts " , column : " linked_account_id "
2023-05-21 17:59:36 +03:00
add_foreign_key " active_storage_attachments " , " active_storage_blobs " , column : " blob_id "
add_foreign_key " active_storage_variant_records " , " active_storage_blobs " , column : " blob_id "
2023-07-01 13:16:07 +03:00
add_foreign_key " document_generation_events " , " submitters "
2026-04-17 14:49:14 +03:00
add_foreign_key " document_metadata " , " accounts "
2026-03-27 12:56:52 +02:00
add_foreign_key " dynamic_document_versions " , " dynamic_documents "
2026-02-12 09:22:08 +02:00
add_foreign_key " dynamic_documents " , " templates "
2024-06-04 11:48:02 +03:00
add_foreign_key " email_events " , " accounts "
2026-06-29 12:30:10 +03:00
add_foreign_key " email_message_assets " , " accounts "
2023-11-23 20:03:52 +02:00
add_foreign_key " email_messages " , " accounts "
add_foreign_key " email_messages " , " users " , column : " author_id "
2023-05-21 17:59:36 +03:00
add_foreign_key " encrypted_configs " , " accounts "
2023-09-25 01:57:10 +03:00
add_foreign_key " encrypted_user_configs " , " users "
2026-03-27 12:56:52 +02:00
add_foreign_key " mcp_tokens " , " users "
2024-07-13 19:26:37 +03:00
add_foreign_key " oauth_access_grants " , " oauth_applications " , column : " application_id "
add_foreign_key " oauth_access_grants " , " users " , column : " resource_owner_id "
add_foreign_key " oauth_access_tokens " , " oauth_applications " , column : " application_id "
add_foreign_key " oauth_access_tokens " , " users " , column : " resource_owner_id "
2025-11-21 11:17:20 +02:00
add_foreign_key " submission_events " , " accounts "
2023-09-10 12:55:41 +03:00
add_foreign_key " submission_events " , " submissions "
add_foreign_key " submission_events " , " submitters "
2023-05-31 23:19:20 +03:00
add_foreign_key " submissions " , " templates "
2023-06-29 02:04:17 +03:00
add_foreign_key " submissions " , " users " , column : " created_by_user_id "
2026-03-27 12:56:52 +02:00
add_foreign_key " submitter_versions " , " submitters "
2023-06-13 00:29:07 +03:00
add_foreign_key " submitters " , " submissions "
2024-12-08 01:37:20 +02:00
add_foreign_key " template_accesses " , " templates "
2023-09-21 00:23:38 +03:00
add_foreign_key " template_folders " , " accounts "
2025-07-20 08:28:19 +03:00
add_foreign_key " template_folders " , " template_folders " , column : " parent_folder_id "
2023-09-21 00:23:38 +03:00
add_foreign_key " template_folders " , " users " , column : " author_id "
2024-02-03 22:37:17 +02:00
add_foreign_key " template_sharings " , " templates "
2026-05-07 09:48:25 +03:00
add_foreign_key " template_versions " , " accounts "
add_foreign_key " template_versions " , " templates "
add_foreign_key " template_versions " , " users " , column : " author_id "
2023-05-31 23:19:20 +03:00
add_foreign_key " templates " , " accounts "
2023-09-21 00:23:38 +03:00
add_foreign_key " templates " , " template_folders " , column : " folder_id "
2023-05-31 23:19:20 +03:00
add_foreign_key " templates " , " users " , column : " author_id "
2023-09-22 21:50:39 +03:00
add_foreign_key " user_configs " , " users "
2023-05-21 17:59:36 +03:00
add_foreign_key " users " , " accounts "
2024-07-14 21:38:24 +03:00
add_foreign_key " webhook_urls " , " accounts "
2023-05-21 17:59:36 +03:00
end