| @@ -10,9 +10,9 @@ | ||
| 10 | 10 | public static function getSqlSchema(): string |
| 11 | 11 | { |
| 12 | 12 | return "`id` BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 13 | 13 | `order_id` BIGINT(20) UNSIGNED NOT NULL, |
| 14 | - `tax_rate_id` BIGINT(20) UNSIGNED NOT NULL, | |
| 14 | + `tax_rate_id` BIGINT(20) NOT NULL, | |
| 15 | 15 | `shipping_tax` BIGINT NULL, |
| 16 | 16 | `order_tax` BIGINT NULL, |
| 17 | 17 | `total_tax` BIGINT NULL, |
| 18 | 18 | `meta` json DEFAULT NULL, |
| @@ -24,10 +24,18 @@ | ||
| 24 | 24 | public static function migrated() |
| 25 | 25 | { |
| 26 | 26 | static::addMetaColumn(); |
| 27 | 27 | static::addFiledAtColumn(); |
| 28 | + static::allowVirtualTaxRateIds(); | |
| 28 | 29 | static::deduplicateOrderTaxRates(); |
| 29 | 30 | static::addOrderTaxRateUniqueIndex(); |
| 31 | + } | |
| 32 | + | |
| 33 | + public static function allowVirtualTaxRateIds() | |
| 34 | + { | |
| 35 | + // EU VAT registration rates are virtual and use negative IDs. Keep zero | |
| 36 | + // reserved for the no-tax sentinel while allowing those rows to persist. | |
| 37 | + static::modifyColumnIfExists('tax_rate_id', 'BIGINT(20) NOT NULL'); | |
| 30 | 38 | } |
| 31 | 39 | |
| 32 | 40 | public static function deduplicateOrderTaxRates() |
| 33 | 41 | { |