PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / trunk
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration vtrunk
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 / TaskMigrator.php

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

78 lines 4.2 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 TaskMigrator
6 {
7 /**
8 * Task Management 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_tasks';
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 'Parent task_id if Subtask',
26 `board_id` INT UNSIGNED NULL,
27 `crm_contact_id` BIGINT UNSIGNED NULL COMMENT 'User ID, Contact ID, Deal ID, Subscriber ID etc.',
28 `title` TEXT NULL COMMENT 'Title or Name of the Task , It can be longer than 255 characters.',
29 `slug` VARCHAR(255) NULL,
30 `type` VARCHAR(50) NULL COMMENT 'task, deal, idea, to-do etc.',
31 `status` VARCHAR(50) NULL DEFAULT 'open' COMMENT 'open, completed, for Boards, Won or Lost for Pipelines',
32 `stage_id` INT UNSIGNED NULL,
33 `source` VARCHAR(50) NULL DEFAULT 'web' COMMENT 'web, funnel, contact-section etc.',
34 `source_id` VARCHAR(255) NULL,
35 `priority` VARCHAR(50) NULL DEFAULT NULL COMMENT 'urgent, high, medium, low',
36 `description` LONGTEXT NULL,
37 `lead_value` DECIMAL(10,2) DEFAULT 0.00,
38 `created_by` BIGINT UNSIGNED NULL,
39 `position` decimal(10,2) NOT NULL DEFAULT '1' COMMENT 'Position of the stage or label. 1 = first, 2 = second, etc.',
40 `comments_count` INT UNSIGNED NULL DEFAULT 0,
41 `issue_number` INT UNSIGNED NULL COMMENT 'Board Specific Issue Number to track the task',
42 `reminder_type` VARCHAR(100) NULL DEFAULT 'none',
43 `settings` TEXT NULL COMMENT 'Serialized',
44 `remind_at` TIMESTAMP NULL,
45 `started_at` TIMESTAMP NULL,
46 `due_at` TIMESTAMP NULL,
47 `last_completed_at` TIMESTAMP NULL,
48 `archived_at` TIMESTAMP NULL,
49 `created_at` TIMESTAMP NULL,
50 `updated_at` TIMESTAMP NULL,
51 KEY `type` (`type`),
52 KEY `board_id` (`board_id`),
53 KEY `slug` (`slug`),
54 KEY `comments_count` (`comments_count`),
55 KEY `issue_number` (`issue_number`),
56 KEY `crm_contact_id` (`crm_contact_id`),
57 KEY `due_at` (`due_at`),
58 KEY `priority` (`priority`)
59 ) $charsetCollate;";
60 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
61 dbDelta($sql);
62 } else {
63 $column_name = 'source_id';
64 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name and column name cannot be prepared
65 $preparedQuery = $wpdb->prepare("DESCRIBE $table %s", $column_name);
66 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Variable contains prepared query, schema check, caching not applicable
67 $dataType = $wpdb->get_row($preparedQuery);
68 if (strpos($dataType->Type, 'int') !== false) {
69 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name and column name cannot be prepared
70 $sql = $wpdb->prepare("ALTER TABLE $table MODIFY $column_name VARCHAR(255) NULL");
71 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Variable contains prepared query, schema modification, caching not applicable
72 $wpdb->query($sql);
73 }
74 }
75
76 }
77 }
78