PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
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
← All changes | database/Migrations/SubscriptionsMigrator.php +46 -1 1.3.25 → 1.6.5 View file →
@@ -8,8 +8,10 @@
8 8
9 9 public static string $tableName = "fct_subscriptions";
10 10
11 11
12 + const CUSTOMER_RECOVERY_INDEX = 'idx_subscriptions_customer_recovery';
13 +
12 14 public static function getSqlSchema(): string
13 15 {
14 16 $indexPrefix = static::getDbPrefix() . 'fct_index_';
15 17
@@ -46,18 +48,52 @@
46 48 `config` json DEFAULT NULL,
47 49 `created_at` DATETIME NULL,
48 50 `updated_at` DATETIME NULL,
49 51
50 - INDEX `{$indexPrefix}_order_subscription_idx` (`parent_order_id` ASC)";
52 + INDEX `{$indexPrefix}_order_subscription_idx` (`parent_order_id` ASC),
53 + INDEX `{$indexPrefix}vendor_subscription_id_idx` (`vendor_subscription_id` ASC),
54 + INDEX `{$indexPrefix}_expiry_scan_idx` (`status`, `next_billing_date`, `id`),
55 + INDEX `{$indexPrefix}collection_method_idx` (`collection_method`),
56 + INDEX `" . self::CUSTOMER_RECOVERY_INDEX . "` (`customer_id` ASC, `id` ASC)";
51 57 }
52 58
53 59 public static function migrated()
54 60 {
61 + static::addCustomerRecoveryIndex();
55 62 static::addUuidColumn();
56 63 static::renameInitialAmountToSignupFee();
57 64 static::backfillEmptyUuids();
65 + static::addVendorSubscriptionIdIndex();
66 + static::addExpiryScanIndex();
67 + static::addCollectionMethodIndex();
58 68 }
59 69
70 + // Serves the store-managed cron guard: whereIn(collection_method,[manual,system])->exists().
71 + // Online DDL, builds over existing rows; column is NOT NULL so no legacy backfill.
72 + public static function addCollectionMethodIndex()
73 + {
74 + static::addIndexIfNotExists(
75 + static::getDbPrefix() . 'fct_index_collection_method_idx',
76 + 'collection_method'
77 + );
78 + }
79 +
80 + public static function addVendorSubscriptionIdIndex()
81 + {
82 + static::addIndexIfNotExists(
83 + static::getDbPrefix() . 'fct_index_vendor_subscription_id_idx',
84 + 'vendor_subscription_id'
85 + );
86 + }
87 +
88 + public static function addExpiryScanIndex()
89 + {
90 + static::addIndexIfNotExists(
91 + static::getDbPrefix() . 'fct_index_expiry_scan_idx',
92 + ['status', 'next_billing_date', 'id']
93 + );
94 + }
95 +
60 96 public static function addUuidColumn()
61 97 {
62 98 // "ALTER TABLE %i ADD COLUMN `uuid` VARCHAR(100) NOT NULL DEFAULT '' AFTER `id`"
63 99 static::addColumnIfNotExists('uuid', "VARCHAR(100) NOT NULL DEFAULT ''", 'id');
@@ -95,6 +131,15 @@
95 131 }
96 132
97 133 (new Subscription())->batchUpdate($uuids);
98 134 } while ($subscriptions->count() >= $chunkSize);
135 + }
136 + public static function addCustomerRecoveryIndex(): void
137 + {
138 + static::addIndexIfNotExists(self::CUSTOMER_RECOVERY_INDEX, ['customer_id', 'id']);
139 + }
140 +
141 + public static function hasCustomerRecoveryIndex(): bool
142 + {
143 + return static::hasIndex(self::CUSTOMER_RECOVERY_INDEX);
99 144 }
100 145 }