prefix.DB::$namespace.'_whatsapp_webhooks'; } public function __construct() { parent::__construct(); $this->table_name = $this->prefix.'_whatsapp_webhooks'; $this->primary_key = 'id'; $this->version = '1.0'; } public function sql_create() { return "CREATE TABLE {$this->table_name} ( id bigint(20) NOT NULL AUTO_INCREMENT, restaurant_id bigint(20) DEFAULT NULL, provider varchar(20) NOT NULL, message_id bigint(20) DEFAULT NULL, conversation_id bigint(20) DEFAULT NULL, message_sid varchar(50) DEFAULT NULL, account_sid varchar(50) DEFAULT NULL, event_type varchar(50) NOT NULL, status varchar(30) DEFAULT NULL, phone_from varchar(50) DEFAULT NULL, phone_to varchar(50) DEFAULT NULL, error_code varchar(20) DEFAULT NULL, error_message text DEFAULT NULL, channel_prefix varchar(20) DEFAULT NULL, raw_payload longtext DEFAULT NULL, processed tinyint(1) DEFAULT 0, processed_at datetime DEFAULT NULL, date_created datetime NOT NULL, PRIMARY KEY (id), KEY `wa_hook_restaurant_id_foreign` (`restaurant_id`), CONSTRAINT `wa_hook_restaurant_id_foreign` FOREIGN KEY (`restaurant_id`) REFERENCES `{$this->prefix}_restaurants` (`id`) ON DELETE CASCADE, KEY `wa_hook_message_id_foreign` (`message_id`), CONSTRAINT `wa_hook_message_id_foreign` FOREIGN KEY (`message_id`) REFERENCES `{$this->prefix}_whatsapp_messages` (`id`) ON DELETE SET NULL, KEY `wa_hook_conversation_id_foreign` (`conversation_id`), CONSTRAINT `wa_hook_conversation_id_foreign` FOREIGN KEY (`conversation_id`) REFERENCES `{$this->prefix}_whatsapp_conversations` (`id`) ON DELETE CASCADE, KEY `wa_hook_message_sid` (`message_sid`), KEY `wa_hook_event_type` (`event_type`), KEY `wa_hook_status` (`status`), KEY `wa_hook_processed` (`processed`), KEY `wa_hook_date_created` (`date_created`) )"; } public function sql_update_columns_releases() { $queries = []; $this->run_queries_updates($queries); } } SRR_DB_Whatsapp_Webhooks::init();