PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.5.4
Fluent Support – Helpdesk & Customer Support Ticket System v1.5.4
2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 68 releases
fluent-support / database / Migrations / TicketsMigrator.php

TicketsMigrator.php in Fluent Support – Helpdesk & Customer Support Ticket System 1.5.4, at database/Migrations/TicketsMigrator.php

60 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\Database\Migrations;
4
5 class TicketsMigrator
6 {
7 static $tableName = 'fs_tickets';
8
9 public static function migrate()
10 {
11 global $wpdb;
12
13 $charsetCollate = $wpdb->get_charset_collate();
14
15 $table = $wpdb->prefix . static::$tableName;
16
17 if ($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) {
18 $sql = "CREATE TABLE $table (
19 `id` BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
20 `customer_id` BIGINT(20) UNSIGNED NULL,
21 `agent_id` BIGINT(20) UNSIGNED NULL,
22 `mailbox_id` BIGINT(20) UNSIGNED NULL,
23 `product_id` BIGINT(20) UNSIGNED NULL,
24 `product_source` VARCHAR(192) NULL,
25 `privacy` VARCHAR(100) DEFAULT 'private',
26 `priority` VARCHAR(100) DEFAULT 'normal',
27 `client_priority` VARCHAR(100) DEFAULT 'normal',
28 `status` VARCHAR(100) DEFAULT 'new',
29 `title` VARCHAR(192) NULL,
30 `slug` VARCHAR(192) NULL,
31 `hash` VARCHAR(192) NULL,
32 `content_hash` VARCHAR(192) NULL,
33 `message_id` VARCHAR(192) NULL,
34 `source` VARCHAR(192) NULL,
35 `content` LONGTEXT NULL,
36 `secret_content` LONGTEXT NULL,
37 `last_agent_response` TIMESTAMP NULL,
38 `last_customer_response` TIMESTAMP NULL,
39 `waiting_since` TIMESTAMP NULL,
40 `response_count` INT(11) DEFAULT 0,
41 `first_response_time` INT(11) NULL, /* Seconds took for first contact */
42 `total_close_time` INT(11) NULL, /* Seconds took for closing this ticket */
43 `resolved_at` TIMESTAMP NULL,
44 `closed_by` BIGINT(20) UNSIGNED NULL,
45 `created_at` TIMESTAMP NULL,
46 `updated_at` TIMESTAMP NULL
47 ) $charsetCollate;";
48 dbDelta($sql);
49 } else {
50 // @todo: We will remove this on final release
51 // This is only for beta users
52 $existing_columns = $wpdb->get_col("DESC {$table}", 0);
53 if(!in_array('waiting_since', $existing_columns)) {
54 $query = 'ALTER TABLE '.$table.' ADD `waiting_since` timestamp NULL AFTER `last_customer_response`';
55 $wpdb->query($query);
56 }
57 }
58 }
59 }
60