# fluent-cart/1.6.4/database/Migrations/ShippingMethodsMigrator.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.6.4. 61 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.6.4/code/database/Migrations/ShippingMethodsMigrator.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.6.4/raw/database/Migrations/ShippingMethodsMigrator.php
- Modified: 2026-04-07T13:41:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/1.6.4/code/database/Migrations/ShippingMethodsMigrator.php#L10-L20`.

```php
<?php

namespace FluentCart\Database\Migrations;

class ShippingMethodsMigrator extends Migrator
{
    public static string $tableName = 'fct_shipping_methods';

    public static function getSqlSchema(): string
    {
        $indexPrefix = static::getDbPrefix() . 'fct_sm_';
        return "`id` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
                `zone_id` BIGINT UNSIGNED NOT NULL,
                `title` VARCHAR(192) NOT NULL,
                `type` VARCHAR(50) NOT NULL,
                `settings` LONGTEXT NULL,
                `is_enabled` TINYINT(1) NOT NULL DEFAULT 1,
                `states` json DEFAULT NULL,
                `amount` DECIMAL(10, 2) NULL DEFAULT 0.00,
                `order` INT UNSIGNED NOT NULL DEFAULT 0,
                `meta` json DEFAULT NULL,
                `created_at` DATETIME NULL,
                `updated_at` DATETIME NULL,

                INDEX `{$indexPrefix}_zone_id_idx` (`zone_id` ASC),
                INDEX `{$indexPrefix}_order_idx` (`order` ASC)";
    }

    public static function migrated()
    {
        static::addStatesColumn();
        static::modifyStatesToJson();
        static::addMetaColumn();
        static::changeAmountToDecimal();
    }

    public static function addStatesColumn()
    {
        // "ALTER TABLE %i ADD COLUMN `states` JSON NULL AFTER `is_enabled`"
        static::addColumnIfNotExists('states', 'JSON NULL', 'is_enabled');
    }

    public static function modifyStatesToJson()
    {
        // "ALTER TABLE %i MODIFY COLUMN `states` JSON NULL"
        static::modifyColumnIfExists('states', 'JSON NULL');
    }

    public static function addMetaColumn()
    {
        // "ALTER TABLE %i ADD COLUMN `meta` JSON NULL AFTER `order`"
        static::addColumnIfNotExists('meta', 'JSON NULL', 'order');
    }

    public static function changeAmountToDecimal()
    {
        // "ALTER TABLE %i MODIFY COLUMN `amount` DECIMAL(10, 2) NULL DEFAULT 0.00"
        static::modifyColumnIfExists('amount', 'DECIMAL(10, 2) NULL DEFAULT 0.00');
    }
}

```
