| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\Database\Migrations; |
| 4 |
|
| 5 |
class OrderTaxRateMigrator extends Migrator |
| 6 |
{ |
| 7 |
|
| 8 |
public static string $tableName = 'fct_order_tax_rate'; |
| 9 |
|
| 10 |
public static function getSqlSchema(): string |
| 11 |
{ |
| 12 |
return "`id` BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 13 |
`order_id` BIGINT(20) UNSIGNED NOT NULL, |
| 14 |
`tax_rate_id` BIGINT(20) UNSIGNED NOT NULL, |
| 15 |
`shipping_tax` BIGINT NULL, |
| 16 |
`order_tax` BIGINT NULL, |
| 17 |
`total_tax` BIGINT NULL, |
| 18 |
`meta` json DEFAULT NULL, |
| 19 |
`filed_at` DATETIME NULL, |
| 20 |
`created_at` DATETIME NULL, |
| 21 |
`updated_at` DATETIME NULL"; |
| 22 |
} |
| 23 |
|
| 24 |
public static function migrated() |
| 25 |
{ |
| 26 |
static::addMetaColumn(); |
| 27 |
static::addFiledAtColumn(); |
| 28 |
} |
| 29 |
|
| 30 |
public static function addMetaColumn() |
| 31 |
{ |
| 32 |
// "ALTER TABLE %i ADD COLUMN `meta` JSON" |
| 33 |
static::addColumnIfNotExists('meta', 'JSON'); |
| 34 |
} |
| 35 |
|
| 36 |
public static function addFiledAtColumn() |
| 37 |
{ |
| 38 |
// "ALTER TABLE %i ADD COLUMN `filed_at` DATETIME NULL AFTER `meta`" |
| 39 |
static::addColumnIfNotExists('filed_at', 'DATETIME NULL', 'meta'); |
| 40 |
} |
| 41 |
} |
| 42 |
|