diff --git a/app/models/access_token.rb b/app/models/access_token.rb index 4bb16771..9de1b6f1 100644 --- a/app/models/access_token.rb +++ b/app/models/access_token.rb @@ -4,7 +4,7 @@ # # Table name: access_tokens # -# id :integer not null, primary key +# id :bigint not null, primary key # sha256 :string not null # token :text not null # created_at :datetime not null @@ -18,7 +18,7 @@ # # Foreign Keys # -# user_id (user_id => users.id) +# fk_rails_... (user_id => users.id) # class AccessToken < ApplicationRecord TOKEN_LENGTH = 43 diff --git a/app/models/account.rb b/app/models/account.rb index a050f336..6265734d 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -4,7 +4,7 @@ # # Table name: accounts # -# id :integer not null, primary key +# id :bigint not null, primary key # archived_at :datetime # locale :string not null # name :string not null diff --git a/app/models/account_access.rb b/app/models/account_access.rb index 67a3ca43..27be6140 100644 --- a/app/models/account_access.rb +++ b/app/models/account_access.rb @@ -4,7 +4,7 @@ # # Table name: account_accesses # -# id :integer not null, primary key +# id :bigint not null, primary key # created_at :datetime not null # updated_at :datetime not null # account_id :integer not null @@ -16,7 +16,7 @@ # # Foreign Keys # -# account_id (account_id => accounts.id) +# fk_rails_... (account_id => accounts.id) # class AccountAccess < ApplicationRecord belongs_to :account diff --git a/app/models/account_config.rb b/app/models/account_config.rb index 4c2d30af..d9adbe65 100644 --- a/app/models/account_config.rb +++ b/app/models/account_config.rb @@ -4,7 +4,7 @@ # # Table name: account_configs # -# id :integer not null, primary key +# id :bigint not null, primary key # key :string not null # value :text not null # created_at :datetime not null @@ -18,7 +18,7 @@ # # Foreign Keys # -# account_id (account_id => accounts.id) +# fk_rails_... (account_id => accounts.id) # class AccountConfig < ApplicationRecord SUBMITTER_INVITATION_EMAIL_KEY = 'submitter_invitation_email' diff --git a/app/models/account_linked_account.rb b/app/models/account_linked_account.rb index 096dc974..16d72b96 100644 --- a/app/models/account_linked_account.rb +++ b/app/models/account_linked_account.rb @@ -4,7 +4,7 @@ # # Table name: account_linked_accounts # -# id :integer not null, primary key +# id :bigint not null, primary key # account_type :text not null # created_at :datetime not null # updated_at :datetime not null @@ -19,8 +19,8 @@ # # Foreign Keys # -# account_id (account_id => accounts.id) -# linked_account_id (linked_account_id => accounts.id) +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (linked_account_id => accounts.id) # class AccountLinkedAccount < ApplicationRecord belongs_to :account diff --git a/app/models/completed_document.rb b/app/models/completed_document.rb index fa08a5ae..5ec53ca4 100644 --- a/app/models/completed_document.rb +++ b/app/models/completed_document.rb @@ -4,7 +4,7 @@ # # Table name: completed_documents # -# id :integer not null, primary key +# id :bigint not null, primary key # sha256 :string not null # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/completed_submitter.rb b/app/models/completed_submitter.rb index 35df279e..6ada62f3 100644 --- a/app/models/completed_submitter.rb +++ b/app/models/completed_submitter.rb @@ -4,7 +4,7 @@ # # Table name: completed_submitters # -# id :integer not null, primary key +# id :bigint not null, primary key # completed_at :datetime not null # sms_count :integer not null # source :string not null diff --git a/app/models/document_generation_event.rb b/app/models/document_generation_event.rb index 60dce188..f4e0a701 100644 --- a/app/models/document_generation_event.rb +++ b/app/models/document_generation_event.rb @@ -4,7 +4,7 @@ # # Table name: document_generation_events # -# id :integer not null, primary key +# id :bigint not null, primary key # event_name :string not null # created_at :datetime not null # updated_at :datetime not null @@ -13,11 +13,11 @@ # Indexes # # index_document_generation_events_on_submitter_id (submitter_id) -# index_document_generation_events_on_submitter_id_and_event_name (submitter_id,event_name) UNIQUE WHERE event_name IN ('start', 'complete') +# index_document_generation_events_on_submitter_id_and_event_name (submitter_id,event_name) UNIQUE WHERE ((event_name)::text = ANY ((ARRAY['start'::character varying, 'complete'::character varying])::text[])) # # Foreign Keys # -# submitter_id (submitter_id => submitters.id) +# fk_rails_... (submitter_id => submitters.id) # class DocumentGenerationEvent < ApplicationRecord belongs_to :submitter diff --git a/app/models/email_event.rb b/app/models/email_event.rb index 3e28712c..3c6aac61 100644 --- a/app/models/email_event.rb +++ b/app/models/email_event.rb @@ -4,7 +4,7 @@ # # Table name: email_events # -# id :integer not null, primary key +# id :bigint not null, primary key # data :text not null # email :string not null # emailable_type :string not null @@ -20,13 +20,13 @@ # # index_email_events_on_account_id_and_event_datetime (account_id,event_datetime) # index_email_events_on_email (email) -# index_email_events_on_email_event_types (email) WHERE event_type IN ('bounce', 'soft_bounce', 'complaint', 'soft_complaint') +# index_email_events_on_email_event_types (email) WHERE ((event_type)::text = ANY ((ARRAY['bounce'::character varying, 'soft_bounce'::character varying, 'complaint'::character varying, 'soft_complaint'::character varying])::text[])) # index_email_events_on_emailable (emailable_type,emailable_id) # index_email_events_on_message_id (message_id) # # Foreign Keys # -# account_id (account_id => accounts.id) +# fk_rails_... (account_id => accounts.id) # class EmailEvent < ApplicationRecord belongs_to :emailable, polymorphic: true diff --git a/app/models/email_message.rb b/app/models/email_message.rb index 4ceef9dc..f61d6d41 100644 --- a/app/models/email_message.rb +++ b/app/models/email_message.rb @@ -4,7 +4,7 @@ # # Table name: email_messages # -# id :integer not null, primary key +# id :bigint not null, primary key # body :text not null # sha1 :string not null # subject :text not null @@ -22,8 +22,8 @@ # # Foreign Keys # -# account_id (account_id => accounts.id) -# author_id (author_id => users.id) +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (author_id => users.id) # class EmailMessage < ApplicationRecord belongs_to :author, class_name: 'User' diff --git a/app/models/encrypted_config.rb b/app/models/encrypted_config.rb index 940f51bc..b826d500 100644 --- a/app/models/encrypted_config.rb +++ b/app/models/encrypted_config.rb @@ -4,7 +4,7 @@ # # Table name: encrypted_configs # -# id :integer not null, primary key +# id :bigint not null, primary key # key :string not null # value :text not null # created_at :datetime not null @@ -18,7 +18,7 @@ # # Foreign Keys # -# account_id (account_id => accounts.id) +# fk_rails_... (account_id => accounts.id) # class EncryptedConfig < ApplicationRecord CONFIG_KEYS = [ diff --git a/app/models/encrypted_user_config.rb b/app/models/encrypted_user_config.rb index ea1f3ca8..cf8d19b0 100644 --- a/app/models/encrypted_user_config.rb +++ b/app/models/encrypted_user_config.rb @@ -4,7 +4,7 @@ # # Table name: encrypted_user_configs # -# id :integer not null, primary key +# id :bigint not null, primary key # key :string not null # value :text not null # created_at :datetime not null @@ -18,7 +18,7 @@ # # Foreign Keys # -# user_id (user_id => users.id) +# fk_rails_... (user_id => users.id) # class EncryptedUserConfig < ApplicationRecord belongs_to :user diff --git a/app/models/submission.rb b/app/models/submission.rb index ffee6140..514bc541 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -4,7 +4,7 @@ # # Table name: submissions # -# id :integer not null, primary key +# id :bigint not null, primary key # archived_at :datetime # expire_at :datetime # name :text @@ -24,16 +24,16 @@ # Indexes # # index_submissions_on_account_id_and_id (account_id,id) -# index_submissions_on_account_id_and_template_id_and_id (account_id,template_id,id) WHERE archived_at IS NULL -# index_submissions_on_account_id_and_template_id_and_id_archived (account_id,template_id,id) WHERE archived_at IS NOT NULL +# index_submissions_on_account_id_and_template_id_and_id (account_id,template_id,id) WHERE (archived_at IS NULL) +# index_submissions_on_account_id_and_template_id_and_id_archived (account_id,template_id,id) WHERE (archived_at IS NOT NULL) # index_submissions_on_created_by_user_id (created_by_user_id) # index_submissions_on_slug (slug) UNIQUE # index_submissions_on_template_id (template_id) # # Foreign Keys # -# created_by_user_id (created_by_user_id => users.id) -# template_id (template_id => templates.id) +# fk_rails_... (created_by_user_id => users.id) +# fk_rails_... (template_id => templates.id) # class Submission < ApplicationRecord belongs_to :template, optional: true diff --git a/app/models/submission_event.rb b/app/models/submission_event.rb index c69b896f..c18b3b97 100644 --- a/app/models/submission_event.rb +++ b/app/models/submission_event.rb @@ -4,7 +4,7 @@ # # Table name: submission_events # -# id :integer not null, primary key +# id :bigint not null, primary key # data :text not null # event_timestamp :datetime not null # event_type :string not null @@ -21,8 +21,8 @@ # # Foreign Keys # -# submission_id (submission_id => submissions.id) -# submitter_id (submitter_id => submitters.id) +# fk_rails_... (submission_id => submissions.id) +# fk_rails_... (submitter_id => submitters.id) # class SubmissionEvent < ApplicationRecord belongs_to :submission diff --git a/app/models/submitter.rb b/app/models/submitter.rb index f95677dd..dc8aa645 100644 --- a/app/models/submitter.rb +++ b/app/models/submitter.rb @@ -4,7 +4,7 @@ # # Table name: submitters # -# id :integer not null, primary key +# id :bigint not null, primary key # completed_at :datetime # declined_at :datetime # email :string @@ -37,7 +37,7 @@ # # Foreign Keys # -# submission_id (submission_id => submissions.id) +# fk_rails_... (submission_id => submissions.id) # class Submitter < ApplicationRecord belongs_to :submission diff --git a/app/models/template.rb b/app/models/template.rb index 00779faa..d3802f05 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -4,7 +4,7 @@ # # Table name: templates # -# id :integer not null, primary key +# id :bigint not null, primary key # archived_at :datetime # fields :text not null # name :string not null @@ -24,8 +24,8 @@ # Indexes # # index_templates_on_account_id (account_id) -# index_templates_on_account_id_and_folder_id_and_id (account_id,folder_id,id) WHERE archived_at IS NULL -# index_templates_on_account_id_and_id_archived (account_id,id) WHERE archived_at IS NOT NULL +# index_templates_on_account_id_and_folder_id_and_id (account_id,folder_id,id) WHERE (archived_at IS NULL) +# index_templates_on_account_id_and_id_archived (account_id,id) WHERE (archived_at IS NOT NULL) # index_templates_on_author_id (author_id) # index_templates_on_external_id (external_id) # index_templates_on_folder_id (folder_id) @@ -33,9 +33,9 @@ # # Foreign Keys # -# account_id (account_id => accounts.id) -# author_id (author_id => users.id) -# folder_id (folder_id => template_folders.id) +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (author_id => users.id) +# fk_rails_... (folder_id => template_folders.id) # class Template < ApplicationRecord DEFAULT_SUBMITTER_NAME = 'First Party' diff --git a/app/models/template_access.rb b/app/models/template_access.rb index 6c909ac5..466f7b4f 100644 --- a/app/models/template_access.rb +++ b/app/models/template_access.rb @@ -4,7 +4,7 @@ # # Table name: template_accesses # -# id :integer not null, primary key +# id :bigint not null, primary key # created_at :datetime not null # updated_at :datetime not null # template_id :integer not null @@ -16,7 +16,7 @@ # # Foreign Keys # -# template_id (template_id => templates.id) +# fk_rails_... (template_id => templates.id) # class TemplateAccess < ApplicationRecord ADMIN_USER_ID = -1 diff --git a/app/models/template_folder.rb b/app/models/template_folder.rb index 26a98234..c470b221 100644 --- a/app/models/template_folder.rb +++ b/app/models/template_folder.rb @@ -4,7 +4,7 @@ # # Table name: template_folders # -# id :integer not null, primary key +# id :bigint not null, primary key # archived_at :datetime # name :string not null # created_at :datetime not null @@ -19,8 +19,8 @@ # # Foreign Keys # -# account_id (account_id => accounts.id) -# author_id (author_id => users.id) +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (author_id => users.id) # class TemplateFolder < ApplicationRecord DEFAULT_NAME = 'Default' diff --git a/app/models/template_sharing.rb b/app/models/template_sharing.rb index 7a41b519..231800f6 100644 --- a/app/models/template_sharing.rb +++ b/app/models/template_sharing.rb @@ -4,7 +4,7 @@ # # Table name: template_sharings # -# id :integer not null, primary key +# id :bigint not null, primary key # ability :string not null # created_at :datetime not null # updated_at :datetime not null @@ -18,7 +18,7 @@ # # Foreign Keys # -# template_id (template_id => templates.id) +# fk_rails_... (template_id => templates.id) # class TemplateSharing < ApplicationRecord ALL_ID = -1 diff --git a/app/models/user.rb b/app/models/user.rb index a2bfcf37..98e500ee 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ # # Table name: users # -# id :integer not null, primary key +# id :bigint not null, primary key # archived_at :datetime # consumed_timestep :integer # current_sign_in_at :datetime @@ -40,7 +40,7 @@ # # Foreign Keys # -# account_id (account_id => accounts.id) +# fk_rails_... (account_id => accounts.id) # class User < ApplicationRecord ROLES = [ diff --git a/app/models/user_config.rb b/app/models/user_config.rb index 898ed3e4..c048ab40 100644 --- a/app/models/user_config.rb +++ b/app/models/user_config.rb @@ -4,7 +4,7 @@ # # Table name: user_configs # -# id :integer not null, primary key +# id :bigint not null, primary key # key :string not null # value :text not null # created_at :datetime not null @@ -18,7 +18,7 @@ # # Foreign Keys # -# user_id (user_id => users.id) +# fk_rails_... (user_id => users.id) # class UserConfig < ApplicationRecord SIGNATURE_KEY = 'signature' diff --git a/app/models/webhook_url.rb b/app/models/webhook_url.rb index 8e98829f..6f3ec5ae 100644 --- a/app/models/webhook_url.rb +++ b/app/models/webhook_url.rb @@ -4,7 +4,7 @@ # # Table name: webhook_urls # -# id :integer not null, primary key +# id :bigint not null, primary key # events :text not null # secret :text not null # sha1 :string not null @@ -20,7 +20,7 @@ # # Foreign Keys # -# account_id (account_id => accounts.id) +# fk_rails_... (account_id => accounts.id) # class WebhookUrl < ApplicationRecord EVENTS = %w[ diff --git a/db/schema.rb b/db/schema.rb index 6a3f0c5f..12ad3824 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,6 +11,9 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema[8.0].define(version: 2025_06_18_085322) do + # These are extensions that must be enabled in order to support this database + enable_extension "pg_catalog.plpgsql" + create_table "access_tokens", force: :cascade do |t| t.integer "user_id", null: false t.text "token", null: false @@ -156,7 +159,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_18_085322) do t.string "event_name", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["submitter_id", "event_name"], name: "index_document_generation_events_on_submitter_id_and_event_name", unique: true, where: "event_name IN ('start', 'complete')" + 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, 'complete'::character varying])::text[]))" t.index ["submitter_id"], name: "index_document_generation_events_on_submitter_id" end @@ -173,7 +176,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_18_085322) do t.datetime "created_at", null: false t.index ["account_id", "event_datetime"], name: "index_email_events_on_account_id_and_event_datetime" t.index ["email"], name: "index_email_events_on_email" - t.index ["email"], name: "index_email_events_on_email_event_types", where: "event_type IN ('bounce', 'soft_bounce', 'complaint', 'soft_complaint')" + t.index ["email"], name: "index_email_events_on_email_event_types", where: "((event_type)::text = ANY ((ARRAY['bounce'::character varying, 'soft_bounce'::character varying, 'complaint'::character varying, 'soft_complaint'::character varying])::text[]))" t.index ["emailable_type", "emailable_id"], name: "index_email_events_on_emailable" t.index ["message_id"], name: "index_email_events_on_message_id" end @@ -284,8 +287,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_18_085322) do t.datetime "expire_at" t.text "name" t.index ["account_id", "id"], name: "index_submissions_on_account_id_and_id" - t.index ["account_id", "template_id", "id"], name: "index_submissions_on_account_id_and_template_id_and_id", where: "archived_at IS NULL" - 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" + t.index ["account_id", "template_id", "id"], name: "index_submissions_on_account_id_and_template_id_and_id", where: "(archived_at IS NULL)" + 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)" t.index ["created_by_user_id"], name: "index_submissions_on_created_by_user_id" t.index ["slug"], name: "index_submissions_on_slug", unique: true t.index ["template_id"], name: "index_submissions_on_template_id" @@ -365,8 +368,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_18_085322) do t.string "external_id" t.text "preferences", null: false t.boolean "shared_link", default: false, null: false - t.index ["account_id", "folder_id", "id"], name: "index_templates_on_account_id_and_folder_id_and_id", where: "archived_at IS NULL" - t.index ["account_id", "id"], name: "index_templates_on_account_id_and_id_archived", where: "archived_at IS NOT NULL" + t.index ["account_id", "folder_id", "id"], name: "index_templates_on_account_id_and_folder_id_and_id", where: "(archived_at IS NULL)" + t.index ["account_id", "id"], name: "index_templates_on_account_id_and_id_archived", where: "(archived_at IS NOT NULL)" t.index ["account_id"], name: "index_templates_on_account_id" t.index ["author_id"], name: "index_templates_on_author_id" t.index ["external_id"], name: "index_templates_on_external_id"