PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.7.5
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.7.5
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 / MetaMigrator.php

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

43 lines 1.5 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 MetaMigrator
6 {
7 /**
8 * Migrate the table.
9 *
10 * @return void
11 */
12 public static function migrate()
13 {
14 global $wpdb;
15
16 $charsetCollate = $wpdb->get_charset_collate();
17
18 $table = $wpdb->prefix . 'fcom_meta';
19 $indexPrefix = $wpdb->prefix . 'fcom_mt_';
20
21 if ($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) {
22 $sql = "CREATE TABLE $table (
23 `id` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
24 `object_type` VARCHAR(50) NOT NULL,
25 `object_id` BIGINT NULL,
26 `meta_key` VARCHAR(100) NOT NULL,
27 `value` LONGTEXT NULL,
28 `created_at` TIMESTAMP NULL,
29 `updated_at` TIMESTAMP NULL,
30 INDEX `{$indexPrefix}_mt_idx` (`object_type` ASC),
31 INDEX `{$indexPrefix}_mto_id_idx` (`object_id` ASC),
32 INDEX `{$indexPrefix}_mto_id_meta_key` (`meta_key` )
33 ) $charsetCollate;";
34 dbDelta($sql);
35 } else {
36 $isMigrated = $wpdb->get_col($wpdb->prepare("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='meta_key' AND TABLE_NAME=%s", $table));
37 if(!$isMigrated) {
38 $wpdb->query("ALTER TABLE {$table} CHANGE `key` `meta_key` varchar(100) NOT NULL AFTER `object_id`");
39 }
40 }
41 }
42 }
43