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 / XProfileMigrator.php

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

50 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable
3
4 namespace FluentCommunity\Database\Migrations;
5
6 class XProfileMigrator
7 {
8 /**
9 * Migrate the table.
10 *
11 * @return void
12 */
13 public static function migrate()
14 {
15 global $wpdb;
16
17 $charsetCollate = $wpdb->get_charset_collate();
18
19 $table = $wpdb->prefix . 'fcom_xprofile';
20 $indexPrefix = $wpdb->prefix . 'fcom_xp_';
21
22 if ($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) {
23 $sql = "CREATE TABLE $table (
24 `id` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
25 `user_id` BIGINT UNSIGNED NOT NULL UNIQUE,
26 `total_points` INT(11) UNSIGNED NOT NULL DEFAULT 0,
27 `username` VARCHAR(100) NULL,
28 `status` enum('active', 'blocked', 'pending') NOT NULL DEFAULT 'active',
29 `is_verified` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
30 `display_name` VARCHAR(192) NULL,
31 `avatar` TEXT NULL,
32 `short_description` TEXT NULL,
33 `last_activity` DATETIME NULL,
34 `meta` LONGTEXT NULL,
35 `created_at` TIMESTAMP NULL,
36 `updated_at` TIMESTAMP NULL,
37 INDEX `{$indexPrefix}_user_id` (`user_id`),
38 INDEX `{$indexPrefix}_username` (`username`),
39 INDEX `{$indexPrefix}_last_activity` (`last_activity`)
40 ) $charsetCollate;";
41 dbDelta($sql);
42 }
43
44 $indexNames = $wpdb->get_col("SHOW INDEX FROM $table", 2);
45 if (!in_array("{$indexPrefix}_last_activity", $indexNames, true)) {
46 $wpdb->query("ALTER TABLE $table ADD INDEX `{$indexPrefix}_last_activity` (`last_activity`)");
47 }
48 }
49 }
50