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
|
||||
Reference in New Issue
Block a user