PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.95.3
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.95.3
2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 1.45 All 41 releases
fluent-boards / database / Migrations / BoardTermMigrator.php

BoardTermMigrator.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.95.3, at database/Migrations/BoardTermMigrator.php

62 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\Database\Migrations;
4
5 class BoardTermMigrator
6 {
7 /**
8 * @param $isForced
9 * @return void
10 */
11 public static function migrate($isForced = true)
12 {
13 global $wpdb;
14
15 $charsetCollate = $wpdb->get_charset_collate();
16 $table = $wpdb->prefix . 'fbs_board_terms';
17 /*
18 * This Schema is for the Board Labels and Stages
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 `board_id` INT UNSIGNED NOT NULL,
26 `title` VARCHAR(100) NULL COMMENT 'Title of the stage or label. Incase of label tile can be null with color only',
27 `slug` VARCHAR(100) NULL COMMENT 'Slug of the stage or label',
28 `type` VARCHAR(50) NOT NULL DEFAULT 'stage' COMMENT 'stage or label',
29 `position` decimal(10,2) NOT NULL DEFAULT '1' COMMENT 'Position of the stage or label. 1 = first, 2 = second, etc.',
30 `color` VARCHAR(50) NULL COMMENT 'Text Color of the stage or label',
31 `bg_color` VARCHAR(50) NULL COMMENT 'Background Color of the stage or label',
32 `settings` TEXT NULL COMMENT 'Serialized Settings',
33 `archived_at` TIMESTAMP NULL,
34 `created_at` TIMESTAMP NULL,
35 `updated_at` TIMESTAMP NULL,
36 KEY `title` (`title`),
37 KEY `type` (`type`),
38 KEY `position` (`position`),
39 KEY `slug` (`slug`)
40 ) $charsetCollate;";
41 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
42 dbDelta($sql);
43 } else {
44 // change column type from int to decimal - for already installed sites
45 $column_name = 'position';
46 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name and column name cannot be prepared
47 $preparedQuery = $wpdb->prepare("DESCRIBE $table %s", $column_name);
48 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Variable contains prepared query, schema check, caching not applicable
49 $dataType = $wpdb->get_row($preparedQuery);
50 if (strpos($dataType->Type, 'int') !== false) {
51 $sql = $wpdb->prepare(
52 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name and column name cannot be prepared
53 "ALTER TABLE $table MODIFY $column_name decimal(10,2) NOT NULL DEFAULT '1' COMMENT 'Position: 1 = top/first, 2 = second/second in top, etc.';"
54 );
55 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Variable contains prepared query, schema modification, caching not applicable
56 $wpdb->query($sql);
57 }
58 }
59
60 }
61 }
62