PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.01
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.01
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
fluent-community / database / Migrations / FeedMigrator.php

FeedMigrator.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.10.01, at database/Migrations/FeedMigrator.php

65 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable
3 namespace FluentCommunity\Database\Migrations;
4
5 class FeedMigrator
6 {
7 /**
8 * @param bool $isForced
9 * @return void
10 */
11 public static function migrate($isForced = false)
12 {
13 global $wpdb;
14
15 $charsetCollate = $wpdb->get_charset_collate();
16 $table = $wpdb->prefix . 'fcom_posts';
17
18 if ($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table || $isForced) {
19 $sql = "CREATE TABLE $table (
20 `id` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
21 `user_id` BIGINT UNSIGNED NULL,
22 `parent_id` BIGINT UNSIGNED NULL,
23 `title` VARCHAR(192) NULL,
24 `slug` VARCHAR(192) NULL,
25 `message` LONGTEXT NULL,
26 `message_rendered` LONGTEXT NULL,
27 `type` VARCHAR(100) NULL DEFAULT 'feed',
28 `content_type` VARCHAR(100) NULL DEFAULT 'text',
29 `space_id` BIGINT UNSIGNED NULL,
30 `privacy` VARCHAR(100) NULL DEFAULT 'public',
31 `status` VARCHAR(100) NULL DEFAULT 'published',
32 `featured_image` TEXT NULL,
33 `meta` LONGTEXT NULL,
34 `is_sticky` TINYINT(1) NULL DEFAULT 0,
35 `comments_count` INT(11) NULL DEFAULT 0,
36 `reactions_count` INT(11) NULL DEFAULT 0,
37 `priority` INT(11) NULL DEFAULT 0,
38 `expired_at` DATETIME NULL,
39 `scheduled_at` DATETIME NULL,
40 `created_at` TIMESTAMP NULL,
41 `updated_at` TIMESTAMP NULL,
42 INDEX `user_id` (`user_id`),
43 INDEX `slug` (`slug`),
44 INDEX `created_at` (`created_at`),
45 INDEX `idx_space_id_status` (`space_id`, `status`),
46 INDEX `idx_space_id_status_privacy` (`space_id`, `status`, `privacy`),
47 INDEX `idx_status_updated_at` (`status`, `updated_at`)
48 ) $charsetCollate;";
49 dbDelta($sql);
50 } else {
51 // check if scheduled_at is exist or not
52 $isMigrated = $wpdb->get_col($wpdb->prepare("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='scheduled_at' AND TABLE_NAME=%s", $table));
53 if(!$isMigrated) {
54 $wpdb->query("ALTER TABLE {$table} ADD COLUMN `scheduled_at` DATETIME NULL AFTER `expired_at`");
55 }
56
57 // check if the ticker index (status, updated_at) exists or not
58 $hasStatusUpdatedIndex = $wpdb->get_col($wpdb->prepare("SELECT INDEX_NAME FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=%s AND INDEX_NAME='idx_status_updated_at'", $table));
59 if (!$hasStatusUpdatedIndex) {
60 $wpdb->query("ALTER TABLE {$table} ADD INDEX `idx_status_updated_at` (`status`, `updated_at`)");
61 }
62 }
63 }
64 }
65