From 97847e2cd4c7f2577470be16523e50eb9cdba37c Mon Sep 17 00:00:00 2001 From: Tanmay Sharma Date: Tue, 22 Jul 2025 18:10:24 +0400 Subject: [PATCH] add migration file for contact inboxes --- app/models/contact.rb | 2 ++ db/migrate/20250722093235_add_is_verified_to_contacts.rb | 7 +++++++ db/schema.rb | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20250722093235_add_is_verified_to_contacts.rb diff --git a/app/models/contact.rb b/app/models/contact.rb index 83920d9fc..c1eff57d6 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -12,6 +12,7 @@ # custom_attributes :jsonb # email :string # identifier :string +# verified :boolean default(FALSE), not null # last_activity_at :datetime # last_name :string default("") # location :string default("") @@ -25,6 +26,7 @@ # Indexes # # index_contacts_on_account_id (account_id) +# index_contacts_on_account_id_and_verified (account_id,verified) # index_contacts_on_account_id_and_last_activity_at (account_id,last_activity_at DESC NULLS LAST) # index_contacts_on_blocked (blocked) # index_contacts_on_lower_email_account_id (lower((email)::text), account_id) diff --git a/db/migrate/20250722093235_add_is_verified_to_contacts.rb b/db/migrate/20250722093235_add_is_verified_to_contacts.rb new file mode 100644 index 000000000..367f03496 --- /dev/null +++ b/db/migrate/20250722093235_add_is_verified_to_contacts.rb @@ -0,0 +1,7 @@ +class AddIsVerifiedToContacts < ActiveRecord::Migration[7.1] + def change + add_column :contacts, :verified, :boolean, default: false, null: false + + add_index :contacts, [:account_id, :verified], name: 'index_contacts_on_account_id_and_verified' + end +end diff --git a/db/schema.rb b/db/schema.rb index 34637315b..f1d417f3b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2025_07_14_104358) do +ActiveRecord::Schema[7.1].define(version: 2025_07_22_093235) do # These extensions should be enabled to support this database enable_extension "pg_stat_statements" enable_extension "pg_trgm" @@ -538,8 +538,10 @@ ActiveRecord::Schema[7.1].define(version: 2025_07_14_104358) do t.string "location", default: "" t.string "country_code", default: "" t.boolean "blocked", default: false, null: false + t.boolean "verified", default: false, null: false t.index "lower((email)::text), account_id", name: "index_contacts_on_lower_email_account_id" t.index ["account_id", "email", "phone_number", "identifier"], name: "index_contacts_on_nonempty_fields", where: "(((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text))" + t.index ["account_id", "verified"], name: "index_contacts_on_account_id_and_verified" t.index ["account_id", "last_activity_at"], name: "index_contacts_on_account_id_and_last_activity_at", order: { last_activity_at: "DESC NULLS LAST" } t.index ["account_id"], name: "index_contacts_on_account_id" t.index ["account_id"], name: "index_resolved_contact_account_id", where: "(((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text))"