PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.4.7
Fluent Support – Helpdesk & Customer Support Ticket System v1.4.7
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 / PersonsMigrator.php

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

62 lines 2.2 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 PersonsMigrator
6 {
7 static $tableName = 'fs_persons';
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 `first_name` VARCHAR(192) NULL,
21 `last_name` VARCHAR(192) NULL,
22 `email` VARCHAR(192) NULL,
23 `title` VARCHAR(192) NULL,
24 `avatar` VARCHAR(192) NULL,
25 `person_type` VARCHAR(192) DEFAULT 'customer',
26 `status` VARCHAR(192) DEFAULT 'active',
27 `ip_address` VARCHAR(20) NULL,
28 `last_ip_address` VARCHAR(20) NULL,
29 `address_line_1` VARCHAR(192) NULL,
30 `address_line_2` VARCHAR(192) NULL,
31 `city` VARCHAR(192) NULL,
32 `zip` VARCHAR(192) NULL,
33 `state` VARCHAR(192) NULL,
34 `country` VARCHAR(192) NULL,
35 `note` LONGTEXT NULL,
36 `hash` VARCHAR(192) NULL,
37 `user_id` BIGINT(20) UNSIGNED NULL,
38 `description` MEDIUMTEXT NULL,
39 `remote_uid` BIGINT(20) UNSIGNED NULL,
40 `last_response_at` TIMESTAMP NULL,
41 `created_at` TIMESTAMP NULL,
42 `updated_at` TIMESTAMP NULL
43 ) $charsetCollate;";
44 dbDelta($sql);
45 } else {
46 // @todo: We will remove this on final release
47 // This is only for beta users
48 $existing_columns = $wpdb->get_col("DESC {$table}", 0);
49 if(!in_array('title', $existing_columns)) {
50 $query = 'ALTER TABLE '.$table.' ADD `title` VARCHAR(192) NULL AFTER `email`';
51 $wpdb->query($query);
52 }
53
54 if(!in_array('description', $existing_columns)) {
55 $query = 'ALTER TABLE '.$table.' ADD `description` MEDIUMTEXT NULL AFTER `user_id`';
56 $wpdb->query($query);
57 }
58
59 }
60 }
61 }
62