feat: Add contact_type attribute to contact model (#8768)

This commit is contained in:
Muhsin Keloth
2024-01-24 12:26:47 +05:30
committed by GitHub
parent 232369cd5c
commit 143299f138
3 changed files with 10 additions and 1 deletions

View File

@@ -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(

View File

@@ -0,0 +1,5 @@
class AddContactTypeToContacts < ActiveRecord::Migration[7.0]
def change
add_column :contacts, :contact_type, :integer, default: 0
end
end

View File

@@ -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"