PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.4.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.4.1
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
fluent-cart / database / Migrations / AttributeGroupsMigrator.php

AttributeGroupsMigrator.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.4.1, at database/Migrations/AttributeGroupsMigrator.php

51 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\Database\Migrations;
4
5 class AttributeGroupsMigrator extends Migrator
6 {
7 public static string $tableName = 'fct_atts_groups';
8
9 public static function getSqlSchema(): string
10 {
11 return "`id` BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
12 `title` VARCHAR(192) NOT NULL,
13 `slug` VARCHAR(192) NOT NULL UNIQUE,
14 `description` longtext NULL,
15 `settings` longtext NULL,
16 `created_at` DATETIME NULL,
17 `updated_at` DATETIME NULL";
18 }
19
20 public static function migrated()
21 {
22 static::dropLegacyTitleUniqueIndexes();
23 }
24
25 public static function dropLegacyTitleUniqueIndexes()
26 {
27 global $wpdb;
28
29 $tableName = static::getTableName();
30
31 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
32 $indexes = $wpdb->get_results($wpdb->prepare(
33 "SHOW INDEX FROM %i WHERE Column_name = %s",
34 $tableName,
35 'title'
36 ), ARRAY_A);
37
38 if (empty($indexes)) {
39 return;
40 }
41
42 foreach ($indexes as $index) {
43 if (($index['Non_unique'] ?? '1') !== '0') {
44 continue;
45 }
46
47 static::dropIndexIfExists($index['Key_name']);
48 }
49 }
50 }
51