PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.27
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.27
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
fluent-cart / database / Migrations / ProductVariationMigrator.php

ProductVariationMigrator.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.27, at database/Migrations/ProductVariationMigrator.php

57 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\Database\Migrations;
4
5 class ProductVariationMigrator extends Migrator
6 {
7 public static string $tableName = 'fct_product_variations';
8
9 public static function getSqlSchema(): string
10 {
11 $indexPrefix = static::getDbPrefix() . 'fct_pd_var_';
12 return "`id` BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
13 `post_id` BIGINT(20) UNSIGNED NOT NULL,
14 `media_id` BIGINT(20) UNSIGNED NULL,
15 `serial_index` INT(5) NULL,
16 `sold_individually` TINYINT(1) UNSIGNED NULL DEFAULT 0,
17 `variation_title` VARCHAR(192) NOT NULL,
18 `variation_identifier` VARCHAR(100) NULL,
19 `sku` VARCHAR(30) NULL DEFAULT NULL,
20 `manage_stock` TINYINT(1) NULL DEFAULT 0,
21 `payment_type` VARCHAR(50) NULL,
22 `stock_status` VARCHAR(30) NULL DEFAULT 'out-of-stock',
23 `backorders` TINYINT(1) UNSIGNED NULL DEFAULT 0,
24 `total_stock` INT(11) NULL DEFAULT 0,
25 `on_hold` INT(11) NULL DEFAULT 0,
26 `committed` INT(11) NULL DEFAULT 0,
27 `available` INT(11) NULL DEFAULT 0,
28 `fulfillment_type` VARCHAR(100) NULL DEFAULT 'physical', /* physicl, digital, service, mixed*/
29 `item_status` VARCHAR(30) NULL DEFAULT 'active',
30 `manage_cost` VARCHAR(30) NULL DEFAULT 'false',
31 `item_price` double DEFAULT 0 NOT NULL,
32 `item_cost` double DEFAULT 0 NOT NULL,
33 `compare_price` double DEFAULT 0 NULL,
34 `shipping_class` BIGINT(20) NULL,
35 `other_info` longtext NULL,
36 `downloadable` VARCHAR(30) NULL DEFAULT 'false',
37 `created_at` DATETIME NULL,
38 `updated_at` DATETIME NULL,
39 INDEX `{$indexPrefix}_post_id_idx` (`post_id` ASC),
40 UNIQUE INDEX `sku_unique` (`sku` ASC),
41 INDEX `{$indexPrefix}_stock_status_idx` (`stock_status` ASC)";
42 }
43
44 public static function migrated()
45 {
46 static::addSkuColumn();
47 }
48
49 public static function addSkuColumn()
50 {
51 // "ALTER TABLE %i ADD COLUMN `sku` VARCHAR(30) NULL DEFAULT NULL AFTER `variation_identifier`"
52 static::addColumnIfNotExists('sku', 'VARCHAR(30) NULL DEFAULT NULL', 'variation_identifier');
53 // "ALTER TABLE %i ADD UNIQUE INDEX `sku_unique` (`sku` ASC)"
54 static::addIndexIfNotExists('sku_unique', 'sku', true);
55 }
56 }
57