| 1 |
<?php |
| 2 |
// phpcs:disable |
| 3 |
|
| 4 |
namespace FluentCommunity\Database\Migrations; |
| 5 |
|
| 6 |
class TermMigrator |
| 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_terms'; |
| 20 |
$indexPrefix = $wpdb->prefix . 'fcom_tm_'; |
| 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 |
`parent_id` BIGINT UNSIGNED NULL, |
| 26 |
`taxonomy_name` VARCHAR(50) NOT NULL, |
| 27 |
`slug` VARCHAR(100) NOT NULL, |
| 28 |
`title` LONGTEXT NULL, |
| 29 |
`description` LONGTEXT NULL, |
| 30 |
`settings` LONGTEXT NULL, |
| 31 |
`created_at` TIMESTAMP NULL, |
| 32 |
`updated_at` TIMESTAMP NULL, |
| 33 |
INDEX `{$indexPrefix}_mt_tax` (`taxonomy_name`), |
| 34 |
INDEX `{$indexPrefix}_mt_slug` (`slug`) |
| 35 |
) $charsetCollate;"; |
| 36 |
dbDelta($sql); |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
|