feat: Add unified Call model for voice calling (#14026)
Adds a Call model to track voice call state across providers (Twilio, WhatsApp). This replaces storing call data in conversation.additional_attributes and provides a foundation for call analytics multi-call-per-conversation support, and future voice providers. --------- Co-authored-by: Muhsin <12408980+muhsin-k@users.noreply.github.com>
This commit is contained in:
34
db/migrate/20260408170902_create_calls.rb
Normal file
34
db/migrate/20260408170902_create_calls.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
class CreateCalls < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :calls do |t|
|
||||
t.bigint :account_id, null: false
|
||||
t.bigint :inbox_id, null: false
|
||||
t.bigint :conversation_id, null: false
|
||||
t.bigint :contact_id, null: false
|
||||
t.bigint :message_id
|
||||
t.bigint :accepted_by_agent_id
|
||||
t.string :provider_call_id, null: false
|
||||
t.integer :provider, null: false, default: 0
|
||||
t.integer :direction, null: false
|
||||
t.string :status, null: false, default: 'ringing'
|
||||
t.datetime :started_at
|
||||
t.integer :duration_seconds
|
||||
t.string :end_reason
|
||||
t.jsonb :meta, default: {}
|
||||
t.text :transcript
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_call_indexes
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_call_indexes
|
||||
add_index :calls, [:provider, :provider_call_id], unique: true
|
||||
add_index :calls, [:account_id, :conversation_id]
|
||||
add_index :calls, [:account_id, :contact_id]
|
||||
add_index :calls, :message_id
|
||||
end
|
||||
end
|
||||
24
db/schema.rb
24
db/schema.rb
@@ -261,6 +261,30 @@ ActiveRecord::Schema[7.1].define(version: 2026_04_09_091202) do
|
||||
t.index ["account_id"], name: "index_automation_rules_on_account_id"
|
||||
end
|
||||
|
||||
create_table "calls", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "inbox_id", null: false
|
||||
t.bigint "conversation_id", null: false
|
||||
t.bigint "contact_id", null: false
|
||||
t.bigint "message_id"
|
||||
t.bigint "accepted_by_agent_id"
|
||||
t.string "provider_call_id", null: false
|
||||
t.integer "provider", default: 0, null: false
|
||||
t.integer "direction", null: false
|
||||
t.string "status", default: "ringing", null: false
|
||||
t.datetime "started_at"
|
||||
t.integer "duration_seconds"
|
||||
t.string "end_reason"
|
||||
t.jsonb "meta", default: {}
|
||||
t.text "transcript"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["account_id", "contact_id"], name: "index_calls_on_account_id_and_contact_id"
|
||||
t.index ["account_id", "conversation_id"], name: "index_calls_on_account_id_and_conversation_id"
|
||||
t.index ["message_id"], name: "index_calls_on_message_id"
|
||||
t.index ["provider", "provider_call_id"], name: "index_calls_on_provider_and_provider_call_id", unique: true
|
||||
end
|
||||
|
||||
create_table "campaigns", force: :cascade do |t|
|
||||
t.integer "display_id", null: false
|
||||
t.string "title", null: false
|
||||
|
||||
Reference in New Issue
Block a user