Fix missing enqueued_at column in twp_queued_calls table
Database Schema Fixes: - Added enqueued_at column migration to twp_queued_calls table - Updated personal queue query to use COALESCE for column compatibility - Enhanced requeue function to handle both enqueued_at and joined_at columns - Added dynamic column detection for backwards compatibility SQL Error Resolution: - Fixes "Unknown column 'qc.enqueued_at' in 'ORDER BY'" errors - Maintains compatibility with existing installations - Ensures proper queue ordering functionality The code now gracefully handles both old (joined_at) and new (enqueued_at) column structures, with automatic migration adding the missing column. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -402,6 +402,13 @@ class TWP_Activator {
|
||||
$wpdb->query("ALTER TABLE $table_queued_calls ADD COLUMN notified_timeout datetime AFTER agent_call_sid");
|
||||
}
|
||||
|
||||
// Add enqueued_at column (some code uses this instead of joined_at)
|
||||
$enqueued_at_exists = $wpdb->get_results("SHOW COLUMNS FROM $table_queued_calls LIKE 'enqueued_at'");
|
||||
if (empty($enqueued_at_exists)) {
|
||||
$wpdb->query("ALTER TABLE $table_queued_calls ADD COLUMN enqueued_at datetime DEFAULT CURRENT_TIMESTAMP AFTER notified_timeout");
|
||||
error_log('TWP: Added enqueued_at column to twp_queued_calls table');
|
||||
}
|
||||
|
||||
// Fix phone number field lengths in call recordings table for outbound calls
|
||||
$table_recordings = $wpdb->prefix . 'twp_call_recordings';
|
||||
|
||||
|
Reference in New Issue
Block a user