| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\Database\Migrations; |
| 4 |
|
| 5 |
class OrderAddressesMigrator extends Migrator |
| 6 |
{ |
| 7 |
public static string $tableName = 'fct_order_addresses'; |
| 8 |
|
| 9 |
public static function getSqlSchema(): string |
| 10 |
{ |
| 11 |
return "`id` BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 12 |
`order_id` BIGINT UNSIGNED NOT NULL, |
| 13 |
`type` VARCHAR(20) NOT NULL DEFAULT 'billing', |
| 14 |
`name` VARCHAR(192) NULL, |
| 15 |
`address_1` VARCHAR(192) NULL, |
| 16 |
`address_2` VARCHAR(192) NULL, |
| 17 |
`city` VARCHAR(192) NULL, |
| 18 |
`state` VARCHAR(192) NULL, |
| 19 |
`postcode` VARCHAR(50) NULL, |
| 20 |
`country` VARCHAR(100) NULL, |
| 21 |
`meta` JSON DEFAULT NULL, |
| 22 |
`created_at` DATETIME NULL, |
| 23 |
`updated_at` DATETIME NULL"; |
| 24 |
} |
| 25 |
|
| 26 |
public static function migrated() |
| 27 |
{ |
| 28 |
static::addMetaColumn(); |
| 29 |
static::addIndexIfNotExists('idx_order_addresses_order_id_type', ['order_id', 'type']); |
| 30 |
} |
| 31 |
|
| 32 |
public static function addMetaColumn() |
| 33 |
{ |
| 34 |
// "ALTER TABLE %i ADD COLUMN `meta` JSON DEFAULT NULL AFTER `country`" |
| 35 |
static::addColumnIfNotExists('meta', 'JSON DEFAULT NULL', 'country'); |
| 36 |
} |
| 37 |
} |
| 38 |
|