PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
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 1.2.0 All 47 releases
fluent-cart / database / Migrations / CustomersMigrator.php

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

51 lines 1.8 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 CustomersMigrator extends Migrator
6 {
7
8 public static string $tableName = 'fct_customers';
9
10 public static function getSqlSchema(): string
11 {
12 $indexPrefix = static::getDbPrefix() . 'fct_cus_';
13
14 return "`id` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
15 `user_id` BIGINT UNSIGNED DEFAULT NULL,
16 `contact_id` BIGINT UNSIGNED NOT NULL DEFAULT '0',
17 `email` VARCHAR(192) NOT NULL DEFAULT '',
18 `first_name` VARCHAR(192) NOT NULL DEFAULT '',
19 `last_name` VARCHAR(192) NOT NULL DEFAULT '',
20 `status` VARCHAR(45) NULL DEFAULT 'active',
21 `purchase_value` json NULL,
22 `purchase_count` BIGINT UNSIGNED NOT NULL DEFAULT '0',
23 `ltv` BIGINT NOT NULL DEFAULT '0',
24 `first_purchase_date` DATETIME NULL,
25 `last_purchase_date` DATETIME NULL,
26 `aov` DECIMAL(18,2) NULL,
27 `notes` LONGTEXT NOT NULL,
28 `uuid` VARCHAR(100) NULL DEFAULT '',
29 `country` VARCHAR(45) NULL,
30 `city` VARCHAR(45) NULL,
31 `state` VARCHAR(45) NULL,
32 `postcode` VARCHAR(45) NULL,
33 `created_at` DATETIME NULL,
34 `updated_at` DATETIME NULL,
35
36 INDEX `{$indexPrefix}_email` (`email` ASC),
37 INDEX `{$indexPrefix}_user_id` (`user_id` ASC)";
38 }
39
40 public static function migrated()
41 {
42 static::addLtvColumn();
43 }
44
45 public static function addLtvColumn()
46 {
47 // "ALTER TABLE %i ADD COLUMN `ltv` BIGINT NOT NULL DEFAULT '0' AFTER `purchase_count`"
48 static::addColumnIfNotExists('ltv', "BIGINT NOT NULL DEFAULT '0'", 'purchase_count');
49 }
50 }
51