| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBoards\Database\Migrations; |
| 4 |
|
| 5 |
class BoardMigrator |
| 6 |
{ |
| 7 |
/** |
| 8 |
* Task Activities Table. |
| 9 |
* |
| 10 |
* @param bool $isForced |
| 11 |
* @return void |
| 12 |
*/ |
| 13 |
public static function migrate($isForced = true) |
| 14 |
{ |
| 15 |
global $wpdb; |
| 16 |
|
| 17 |
$charsetCollate = $wpdb->get_charset_collate(); |
| 18 |
$table = $wpdb->prefix . 'fbs_boards'; |
| 19 |
|
| 20 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Schema check query, caching not applicable for migrations |
| 21 |
if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table)) != $table || $isForced) { |
| 22 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- Table name cannot be prepared in CREATE TABLE |
| 23 |
$sql = "CREATE TABLE $table ( |
| 24 |
`id` INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 25 |
`parent_id` INT UNSIGNED NULL COMMENT 'For SuperBoard like Project or Company, for sub-board etc.', |
| 26 |
`title` TEXT NULL COMMENT 'Title of the board , It can be longer than 255 characters.', |
| 27 |
`description` LONGTEXT NULL, |
| 28 |
`type` VARCHAR(50) NULL COMMENT 'type will be to-do/sales-pipeline/roadmap/task etc.', |
| 29 |
`currency` VARCHAR(50) NULL, |
| 30 |
`background` TEXT NULL COMMENT 'Serialized Array', |
| 31 |
`settings` TEXT NULL COMMENT 'Serialized Array', |
| 32 |
`created_by` INT UNSIGNED NOT NULL, |
| 33 |
`archived_at` TIMESTAMP NULL, |
| 34 |
`created_at` TIMESTAMP NULL, |
| 35 |
`updated_at` TIMESTAMP NULL, |
| 36 |
KEY `parent_id` (`parent_id`), |
| 37 |
KEY `type` (`type`) |
| 38 |
) $charsetCollate;"; |
| 39 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 40 |
dbDelta($sql); |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|