PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.4.0
Fluent Support – Helpdesk & Customer Support Ticket System v1.4.0
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 / AttachmentsMigrator.php

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

47 lines 1.6 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 AttachmentsMigrator
6 {
7 static $tableName = 'fs_attachments';
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 `ticket_id` BIGINT(20) UNSIGNED NULL,
21 `person_id` BIGINT(20) UNSIGNED NULL,
22 `conversation_id` BIGINT(20) UNSIGNED NULL,
23 `file_type` VARCHAR(100) NULL,
24 `file_path` TEXT NULL,
25 `full_url` TEXT NULL,
26 `settings` TEXT NULL,
27 `title` VARCHAR(192) NULL,
28 `file_hash` VARCHAR(192) NULL,
29 `driver` VARCHAR(100) DEFAULT 'local',
30 `status` VARCHAR(100) NULL DEFAULT 'active',
31 `file_size` VARCHAR(100) NULL,
32 `created_at` TIMESTAMP NULL,
33 `updated_at` TIMESTAMP NULL
34 ) $charsetCollate;";
35 dbDelta($sql);
36 } else {
37 // @todo: We will remove this on final release
38 // This is only for beta users
39 $existing_columns = $wpdb->get_col("DESC {$table}", 0);
40 if(!in_array('status', $existing_columns)) {
41 $query = "ALTER TABLE {$table} ADD `status` VARCHAR(100) NULL DEFAULT 'active' AFTER `driver`";
42 $wpdb->query($query);
43 }
44 }
45 }
46 }
47