call( 'deleteWebhook', array(), 5 ); } } /** * Create or upgrade the table when the stored schema version is behind. */ public static function maybe_upgrade() { if ( (int) get_option( self::DB_VERSION_OPTION, 0 ) >= self::DB_VERSION ) { return; } global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $table = Message_Log::table(); $charset = $wpdb->get_charset_collate(); dbDelta( "CREATE TABLE {$table} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, created_at datetime NOT NULL, order_id bigint(20) unsigned NOT NULL DEFAULT 0, channel varchar(20) NOT NULL DEFAULT 'telegram', direction varchar(3) NOT NULL DEFAULT 'out', recipient varchar(10) NOT NULL DEFAULT 'customer', event varchar(40) NOT NULL DEFAULT '', chat_id varchar(32) NOT NULL DEFAULT '', body text NOT NULL, status varchar(12) NOT NULL DEFAULT 'queued', detail varchar(255) NOT NULL DEFAULT '', attempts tinyint(3) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (id), KEY order_id (order_id), KEY created_at (created_at), KEY chat_id (chat_id) ) {$charset};" ); update_option( self::DB_VERSION_OPTION, self::DB_VERSION, false ); } }