| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\Database\Migrations; |
| 4 |
|
| 5 |
class ShippingClassesMigrator extends Migrator |
| 6 |
{ |
| 7 |
public static string $tableName = 'fct_shipping_classes'; |
| 8 |
|
| 9 |
public static function getSqlSchema(): string |
| 10 |
{ |
| 11 |
$indexPrefix = static::getDbPrefix() . 'fct_sc_'; |
| 12 |
return "`id` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 13 |
`name` VARCHAR(192) NOT NULL, |
| 14 |
`description` VARCHAR(500) NULL, |
| 15 |
`cost` DECIMAL(10, 2) NOT NULL DEFAULT 0.00, |
| 16 |
`per_item` TINYINT(1) NOT NULL DEFAULT 0, |
| 17 |
`type` VARCHAR(20) NOT NULL DEFAULT 'fixed', |
| 18 |
`created_at` DATETIME NULL, |
| 19 |
`updated_at` DATETIME NULL, |
| 20 |
|
| 21 |
INDEX `{$indexPrefix}_name_idx` (`name` ASC)"; |
| 22 |
} |
| 23 |
|
| 24 |
public static function migrated() |
| 25 |
{ |
| 26 |
// Ensure description exists on upgrades (fresh installs get it from getSqlSchema) |
| 27 |
static::addColumnIfNotExists('description', 'VARCHAR(500) NULL', 'name'); |
| 28 |
} |
| 29 |
} |
| 30 |
|