diff --git a/app/models/contact.rb b/app/models/contact.rb index ba10139ba..176109f24 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -6,6 +6,7 @@ # # id :integer not null, primary key # additional_attributes :jsonb +# contact_type :integer default("visitor") # custom_attributes :jsonb # email :string # identifier :string @@ -55,6 +56,8 @@ class Contact < ApplicationRecord after_update_commit :dispatch_update_event after_destroy_commit :dispatch_destroy_event + enum contact_type: { visitor: 0, lead: 1, customer: 2 } + scope :order_on_last_activity_at, lambda { |direction| order( Arel::Nodes::SqlLiteral.new( diff --git a/db/migrate/20240124054340_add_contact_type_to_contacts.rb b/db/migrate/20240124054340_add_contact_type_to_contacts.rb new file mode 100644 index 000000000..d6b939a36 --- /dev/null +++ b/db/migrate/20240124054340_add_contact_type_to_contacts.rb @@ -0,0 +1,5 @@ +class AddContactTypeToContacts < ActiveRecord::Migration[7.0] + def change + add_column :contacts, :contact_type, :integer, default: 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 0fcf7ba61..b914eca61 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.0].define(version: 2023_12_23_040257) do +ActiveRecord::Schema[7.0].define(version: 2024_01_24_054340) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "pg_trgm" @@ -418,6 +418,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_12_23_040257) do t.string "identifier" t.jsonb "custom_attributes", default: {} t.datetime "last_activity_at", precision: nil + t.integer "contact_type", default: 0 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"], name: "index_contacts_on_account_id"