| @@ -135,8 +135,10 @@ | ||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public static function maybeMigrateDBChanges() |
| 138 | 138 | { |
| 139 | + self::maybeMigrateCustomerRecoveryIndexes(); | |
| 140 | + | |
| 139 | 141 | /* |
| 140 | 142 | * TODO We will remove this after final release |
| 141 | 143 | */ |
| 142 | 144 | $currentDBVersion = get_option('_fluent_cart_db_version'); |
| @@ -174,8 +176,14 @@ | ||
| 174 | 176 | // 2026-05-27 |
| 175 | 177 | TaxRatesMigrator::fixPostcodeRangeSeparator(); |
| 176 | 178 | OrdersMigrator::addFeeTotalColumn(); |
| 177 | 179 | |
| 180 | + // 2026-07-24 | |
| 181 | + OrdersMigrator::addUuidIndex(); | |
| 182 | + | |
| 183 | + // 2026-08-20 | |
| 184 | + ProductMetaMigrator::addObjectMetaIndex(); | |
| 185 | + | |
| 178 | 186 | // let's check the orders table sequence number |
| 179 | 187 | global $wpdb; |
| 180 | 188 | |
| 181 | 189 | // Product Meta unique index removal |
| @@ -477,9 +485,15 @@ | ||
| 477 | 485 | \FluentCart\Database\Migrations\ShippingZonesMigrator::migrated(); |
| 478 | 486 | \FluentCart\Database\Migrations\ShippingClassesMigrator::migrated(); |
| 479 | 487 | \FluentCart\Database\Migrations\SubscriptionsMigrator::migrated(); |
| 480 | 488 | |
| 489 | + // 2026-08-06 | |
| 490 | + // fct_order_transactions subscription_id index — also run here so | |
| 491 | + // in-place plugin updates deliver it; migrate() only covers the | |
| 492 | + // activation path. | |
| 493 | + \FluentCart\Database\Migrations\OrderTransactionsMigrator::migrated(); | |
| 481 | 494 | |
| 495 | + | |
| 482 | 496 | // 2026-05-06 |
| 483 | 497 | // Backfill, dedup, then add unique index — must run in this order |
| 484 | 498 | // so the constraint can be applied without "Duplicate entry" errors. |
| 485 | 499 | TaxClassesMigrator::backfillNullSlugs(); |
| @@ -583,8 +597,40 @@ | ||
| 583 | 597 | AttributeObjectRelationsMigrator::migrate(); |
| 584 | 598 | AttributeTermsMigrator::migrate(); |
| 585 | 599 | AttributeSeeder::seed(); |
| 586 | 600 | |
| 601 | + self::releaseMigrationLock(); | |
| 602 | + } | |
| 603 | + } | |
| 604 | + | |
| 605 | + /** Upgrade active stores without running index DDL on customer requests. */ | |
| 606 | + public static function maybeMigrateCustomerRecoveryIndexes(): void | |
| 607 | + { | |
| 608 | + $option = '_fluent_cart_customer_recovery_indexes_version'; | |
| 609 | + if (get_option($option) === '1') { | |
| 610 | + return; | |
| 611 | + } | |
| 612 | + if (!(defined('WP_CLI') && WP_CLI) && (!is_admin() || !current_user_can('manage_options'))) { | |
| 613 | + return; | |
| 614 | + } | |
| 615 | + if (!self::acquireMigrationLock()) { | |
| 616 | + return; | |
| 617 | + } | |
| 618 | + try { | |
| 619 | + if (get_option($option) === '1') { | |
| 620 | + return; | |
| 621 | + } | |
| 622 | + foreach ([SubscriptionsMigrator::class, OrderDownloadPermissionsMigrator::class, CartMigrator::class] as $migrator) { | |
| 623 | + if (!Schema::hasTable($migrator::$tableName)) { | |
| 624 | + return; | |
| 625 | + } | |
| 626 | + $migrator::addCustomerRecoveryIndex(); | |
| 627 | + if (!$migrator::hasCustomerRecoveryIndex()) { | |
| 628 | + return; // Keep the upgrade pending if ALTER failed. | |
| 629 | + } | |
| 630 | + } | |
| 631 | + update_option($option, '1', false); | |
| 632 | + } finally { | |
| 587 | 633 | self::releaseMigrationLock(); |
| 588 | 634 | } |
| 589 | 635 | } |
| 590 | 636 | |