|
19 | 19 | use craft\commerce\models\SiteStore; |
20 | 20 | use craft\commerce\models\Store; |
21 | 21 | use craft\commerce\Plugin; |
| 22 | +use craft\commerce\records\CatalogPricingQueue; |
22 | 23 | use craft\commerce\records\CatalogPricingRule; |
23 | 24 | use craft\commerce\records\InventoryLocation; |
24 | 25 | use craft\commerce\records\TaxCategory; |
@@ -132,6 +133,18 @@ public function createTables(): void |
132 | 133 | 'uid' => $this->uid(), |
133 | 134 | ]); |
134 | 135 |
|
| 136 | + $this->archiveTableIfExists(Table::CATALOG_PRICING_QUEUE); |
| 137 | + $this->createTable(Table::CATALOG_PRICING_QUEUE, [ |
| 138 | + 'id' => $this->primaryKey(), |
| 139 | + 'storeId' => $this->integer(), |
| 140 | + 'type' => $this->enum('type', [CatalogPricingQueue::TYPE_PURCHASABLE, CatalogPricingQueue::TYPE_RULE])->notNull(), |
| 141 | + 'ids' => $this->mediumText(), |
| 142 | + 'reserved' => $this->boolean()->notNull()->defaultValue(false), |
| 143 | + 'dateCreated' => $this->dateTime()->notNull(), |
| 144 | + 'dateUpdated' => $this->dateTime()->notNull(), |
| 145 | + 'uid' => $this->uid(), |
| 146 | + ]); |
| 147 | + |
135 | 148 | $this->archiveTableIfExists(Table::CUSTOMERS); |
136 | 149 | $this->createTable(Table::CUSTOMERS, [ |
137 | 150 | 'id' => $this->primaryKey(), // Not used in v4 but is the old customerId |
@@ -1091,6 +1104,8 @@ public function createIndexes(): void |
1091 | 1104 | $this->createIndex(null, Table::CATALOG_PRICING, ['purchasableId', 'storeId', 'isPromotionalPrice', 'price', 'catalogPricingRuleId', 'dateFrom', 'dateTo'], false); |
1092 | 1105 | $this->createIndex(null, Table::CATALOG_PRICING, ['purchasableId', 'storeId', 'isPromotionalPrice', 'price'], false); |
1093 | 1106 | $this->createIndex(null, Table::CATALOG_PRICING, ['purchasableId', 'storeId'], false); |
| 1107 | + $this->createIndex(null, Table::CATALOG_PRICING_QUEUE, 'reserved', false); |
| 1108 | + $this->createIndex(null, Table::CATALOG_PRICING_QUEUE, ['storeId', 'type', 'reserved'], false); |
1094 | 1109 | $this->createIndex(null, Table::CATALOG_PRICING_RULES, 'storeId', false); |
1095 | 1110 | $this->createIndex(null, Table::CATALOG_PRICING_RULES_USERS, 'catalogPricingRuleId', false); |
1096 | 1111 | $this->createIndex(null, Table::CATALOG_PRICING_RULES_USERS, 'userId', false); |
@@ -1215,6 +1230,7 @@ public function addForeignKeys(): void |
1215 | 1230 | $this->addForeignKey(null, Table::CATALOG_PRICING, ['purchasableId'], Table::PURCHASABLES, ['id'], 'CASCADE', 'CASCADE'); |
1216 | 1231 | $this->addForeignKey(null, Table::CATALOG_PRICING, ['storeId'], Table::STORES, ['id'], 'CASCADE'); |
1217 | 1232 | $this->addForeignKey(null, Table::CATALOG_PRICING, ['userId'], CraftTable::USERS, ['id'], 'CASCADE'); |
| 1233 | + $this->addForeignKey(null, Table::CATALOG_PRICING_QUEUE, ['storeId'], Table::STORES, ['id'], 'CASCADE', 'CASCADE'); |
1218 | 1234 | $this->addForeignKey(null, Table::CATALOG_PRICING_RULES, ['storeId'], Table::STORES, ['id'], 'CASCADE', 'CASCADE'); |
1219 | 1235 | $this->addForeignKey(null, Table::CATALOG_PRICING_RULES_USERS, ['catalogPricingRuleId'], Table::CATALOG_PRICING_RULES, ['id'], 'CASCADE', 'CASCADE'); |
1220 | 1236 | $this->addForeignKey(null, Table::CATALOG_PRICING_RULES_USERS, ['userId'], CraftTable::USERS, ['id'], 'CASCADE', 'CASCADE'); |
|
0 commit comments