From ba9adc4c59bb6fe41ce531225e7c41911a96defa Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Thu, 12 Jun 2025 17:41:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=A4=84=E7=90=86=E4=BC=98?= =?UTF-8?q?=E5=8C=96migration=E6=96=87=E4=BB=B6=E4=B8=8Emodel=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AD=97=E6=AE=B5=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/ProductTcoCategoryBaseModel.php | 1 + app/common/model/SysConfigGroupBaseModel.php | 17 ++++++----- ...1220021543_create_product_tco_category.php | 1 + ...20241220062425_create_article_category.php | 2 ++ ...41220094245_create_attachment_category.php | 3 +- ...224032339_create_bulk_purchase_inquiry.php | 2 +- .../20241230064542_create_sys_config.php | 7 +++-- ...20241230080352_create_sys_config_group.php | 3 +- .../20241230082139_create_sys_operate_log.php | 1 + .../20241230090420_create_sys_navigation.php | 3 +- .../20241230095616_create_sys_banner.php | 3 +- ...it.php => AgentEntrypriceSizeTypeInit.php} | 4 +-- database/seeds/ProductAttrInit.php | 30 +++++++++++++++++++ 13 files changed, 58 insertions(+), 19 deletions(-) rename database/seeds/{AgentEnterpriseSizeTypeInit.php => AgentEntrypriceSizeTypeInit.php} (93%) create mode 100644 database/seeds/ProductAttrInit.php diff --git a/app/common/model/ProductTcoCategoryBaseModel.php b/app/common/model/ProductTcoCategoryBaseModel.php index 59c8aeab..d68c56f7 100644 --- a/app/common/model/ProductTcoCategoryBaseModel.php +++ b/app/common/model/ProductTcoCategoryBaseModel.php @@ -25,6 +25,7 @@ class ProductTcoCategoryBaseModel extends BaseModel 'tco_path' => 'string', 'erp_id' => 'int', 'erp_pid' => 'int', + 'erp_code' => 'string', 'erp_path' => 'string', 'disabled' => 'int', 'sync_time' => 'int', diff --git a/app/common/model/SysConfigGroupBaseModel.php b/app/common/model/SysConfigGroupBaseModel.php index b72a71d4..b5a3b418 100644 --- a/app/common/model/SysConfigGroupBaseModel.php +++ b/app/common/model/SysConfigGroupBaseModel.php @@ -17,13 +17,14 @@ class SysConfigGroupBaseModel extends BaseModel // 字段信息 protected $schema = [ - 'id' => 'int', - 'language_id' => 'int', - 'name' => 'string', - 'sort' => 'int', - 'status' => 'int', - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - 'deleted_at' => 'datetime', + 'id' => 'int', + 'language_id' => 'int', + 'unique_label' => 'string', + 'name' => 'string', + 'sort' => 'int', + 'status' => 'int', + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + 'deleted_at' => 'datetime', ]; } diff --git a/database/migrations/20241220021543_create_product_tco_category.php b/database/migrations/20241220021543_create_product_tco_category.php index 352c77f4..4f844f05 100644 --- a/database/migrations/20241220021543_create_product_tco_category.php +++ b/database/migrations/20241220021543_create_product_tco_category.php @@ -35,6 +35,7 @@ class CreateProductTcoCategory extends Migrator ->addColumn('tco_path', 'string', ['limit' => 120, 'default' => null, 'comment' => '产品目录分类上下级关联路径']) ->addColumn('erp_id', 'integer', ['default' => null, 'comment' => '分类在ERP中的ID']) ->addColumn('erp_pid', 'integer', ['default' => null, 'comment' => '分类在ERP中的父级ID']) + ->addColumn('erp_code', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '分类在ERP中的编码']) ->addColumn('erp_path', 'string', ['limit' => 120, 'default' => null, 'comment' => '分类在ERP中的上下级关联路径']) ->addColumn('disabled', 'boolean', ['null' => false, 'default' => 0, 'comment' => '0为启用, 1为禁用']) ->addColumn('sync_time', 'integer', ['null' => false, 'default' => 0, 'comment' => '同步时间']) diff --git a/database/migrations/20241220062425_create_article_category.php b/database/migrations/20241220062425_create_article_category.php index c574423b..dfb5b4fe 100644 --- a/database/migrations/20241220062425_create_article_category.php +++ b/database/migrations/20241220062425_create_article_category.php @@ -31,6 +31,7 @@ class CreateArticleCategory extends Migrator $table = $this->table('article_category', ['engine' => 'MyISAM', 'comment' => '文章分类表']); $table->addColumn('language_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '语言ID']) ->addColumn('pid', 'integer', ['signed' => false, 'null' => false, 'default' => 0, 'comment' => '父级ID']) + ->addColumn('unique_label', 'string', ['limit' => 64, 'null' => false, 'comment' => '唯一标识']) ->addColumn('name', 'string', ['limit' => 64, 'null' => false, 'comment' => '分类名称']) ->addColumn('short_name', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '分类简称']) ->addColumn('icon', 'string', ['limit' => 125, 'default' => null, 'comment' => '图标']) @@ -41,6 +42,7 @@ class CreateArticleCategory extends Migrator ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '新增时间']) ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间']) ->addColumn('deleted_at', 'timestamp', ['null' => true, 'comment' => '删除时间']) + ->addIndex(['language_id', 'unique_label'], ['name' => 'idx_language_id_unique_label', 'unique' => true]) ->create(); } } diff --git a/database/migrations/20241220094245_create_attachment_category.php b/database/migrations/20241220094245_create_attachment_category.php index 9318a367..bb36e969 100644 --- a/database/migrations/20241220094245_create_attachment_category.php +++ b/database/migrations/20241220094245_create_attachment_category.php @@ -28,7 +28,8 @@ class CreateAttachmentCategory extends Migrator public function change() { $table = $this->table('attachment_category', ['engine' => 'MyISAM', 'comment' => '附件分类表']); - $table->addColumn('language_id', 'integer', ['signed' => false , 'null' => false, 'comment' => '语言ID']) + $table->addColumn('pid', 'integer', ['null' => true, 'default' => 0, 'comment' => '上级id']) + ->addColumn('language_id', 'integer', ['signed' => false , 'null' => false, 'comment' => '语言ID']) ->addColumn('name', 'string', ['limit' => 64 , 'null' => false, 'comment' => '分类名称']) ->addColumn('sort', 'integer', ['null' => false, 'default' => 0, 'comment' => '排序']) ->addColumn('is_show', 'boolean', ['null' => false, 'default' => 1, 'comment' => '是否显示:1是,0否']) diff --git a/database/migrations/20241224032339_create_bulk_purchase_inquiry.php b/database/migrations/20241224032339_create_bulk_purchase_inquiry.php index e77a5c50..beb4285a 100644 --- a/database/migrations/20241224032339_create_bulk_purchase_inquiry.php +++ b/database/migrations/20241224032339_create_bulk_purchase_inquiry.php @@ -37,7 +37,7 @@ class CreateBulkPurchaseInquiry extends Migrator ->addColumn('province', 'string', ['limit' => 64, 'null' => true, 'comment' => '省']) ->addColumn('city', 'string', ['limit' => 64, 'null' => true, 'comment' => '市']) ->addColumn('district', 'string', ['limit' => 64, 'null' => true, 'comment' => '区']) - ->addColumn('address', 'string', ['limit' => 255, 'null' => true, 'comment' => '地址']) + ->addColumn('street', 'string', ['limit' => 255, 'null' => true, 'comment' => '街道']) ->addColumn('interested', 'string', ['limit' => 255, 'null' => false, 'comment' => '兴趣(感兴趣的产品品类)']) ->addColumn('url', 'string', ['limit' => 255, 'null' => true, 'comment' => '感兴趣产品所在官网URL']) ->addColumn('referer_url', 'string', ['limit' => 255, 'null' => true, 'comment' => '来源URL']) diff --git a/database/migrations/20241230064542_create_sys_config.php b/database/migrations/20241230064542_create_sys_config.php index fb081563..568a51fb 100644 --- a/database/migrations/20241230064542_create_sys_config.php +++ b/database/migrations/20241230064542_create_sys_config.php @@ -31,14 +31,15 @@ class CreateSysConfig extends Migrator $table->addColumn('group_id', 'integer', ['limit' => 11, 'null' => false, 'comment' => '分组ID']) ->addColumn('title', 'string', ['limit' => 64, 'null' => false, 'comment' => '配置标题']) ->addColumn('name', 'string', ['limit' => 64, 'null' => false, 'comment' => '配置名称']) - ->addColumn('value', 'string', ['limit' => 512, 'null' => true, 'default' => null, 'comment' => '配置值']) - ->addColumn('extra', 'string', ['limit' => 512, 'null' => true, 'default' => null, 'comment' => '配置额外信息']) + ->addColumn('value', 'string', ['limit' => 4096, 'null' => true, 'default' => null, 'comment' => '配置值']) + ->addColumn('extra', 'string', ['limit' => 4096, 'null' => true, 'default' => null, 'comment' => '配置额外信息']) ->addColumn('type', 'string', ['limit' => 64, 'null' => false, 'comment' => '配置类型: text, textarea, number, select, checkbox, radio, date, time, datetime']) ->addColumn('sort', 'integer', ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '排序']) ->addColumn('remark', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '备注']) ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间']) - ->addIndex(['name'], ['unique' => true, 'name' => 'unique_idx_name']) + ->addColumn('deleted_at', 'timestamp', ['null' => true, 'default' => null, 'comment' => '删除时间']) + ->addIndex(['group_id', 'name'], ['unique' => true, 'name' => 'idx_unique_group_id_name']) ->create(); } } diff --git a/database/migrations/20241230080352_create_sys_config_group.php b/database/migrations/20241230080352_create_sys_config_group.php index 4207a7d3..18338333 100644 --- a/database/migrations/20241230080352_create_sys_config_group.php +++ b/database/migrations/20241230080352_create_sys_config_group.php @@ -29,12 +29,13 @@ class CreateSysConfigGroup extends Migrator { $table = $this->table('sys_config_group', ['engine' => 'InnoDB', 'comment' => '系统配置分组表']); $table->addColumn('language_id', 'integer', ['null' => false, 'comment' => '语言ID']) - ->addColumn('unique_label', 'string', ['32' => 64, 'null' => true, 'default' => 'null', 'comment' => '唯一标识']) + ->addColumn('unique_label', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '唯一标识']) ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '分组名称']) ->addColumn('sort', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '排序']) ->addColumn('status', 'boolean', ['limit' => 1, 'default' => 1, 'comment' => '状态 -1禁用, 1启用']) ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间']) + ->addColumn('deleted_at', 'timestamp', ['null' => true, 'default' => null, 'comment' => '删除时间']) ->create(); } } diff --git a/database/migrations/20241230082139_create_sys_operate_log.php b/database/migrations/20241230082139_create_sys_operate_log.php index 429b70b9..c200d279 100644 --- a/database/migrations/20241230082139_create_sys_operate_log.php +++ b/database/migrations/20241230082139_create_sys_operate_log.php @@ -42,6 +42,7 @@ class CreateSysOperateLog extends Migrator ->addColumn('status', MysqlAdapter::PHINX_TYPE_SMALL_INTEGER, ['limit' => 5, 'default' => 200, 'comment' => '状态码']) ->addColumn('message', MysqlAdapter::PHINX_TYPE_TEXT, ['default' => null, 'comment' => '消息']) ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex(['user_id'], ['name' => 'idx_user_id']) ->create(); } } diff --git a/database/migrations/20241230090420_create_sys_navigation.php b/database/migrations/20241230090420_create_sys_navigation.php index 7367f708..6f1f8146 100644 --- a/database/migrations/20241230090420_create_sys_navigation.php +++ b/database/migrations/20241230090420_create_sys_navigation.php @@ -30,6 +30,7 @@ class CreateSysNavigation extends Migrator $table = $this->table('sys_navigation', ['engine' => 'InnoDB', 'comment' => '系统导航表']); $table->addColumn('language_id', 'integer', ['null' => false, 'comment' => '语言ID']) ->addColumn('at_page', 'string', ['limit' => 64, 'null' => true, 'comment' => '导航所在页面路径']) + ->addColumn('at_platform', 'string', ['limit' => 8, 'null' => false, 'comment' => '所在平台: pc为电脑, mobile为手机']) ->addColumn('unique_label', 'string', ['limit' => 64, 'null' => false, 'comment' => '导航唯一标识']) ->addColumn('name', 'string', ['limit' => 64, 'null' => false, 'comment' => '导航名称']) ->addColumn('desc', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '导航描述']) @@ -38,7 +39,7 @@ class CreateSysNavigation extends Migrator ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间']) ->addColumn('deleted_at', 'timestamp', ['null' => true, 'default' => null, 'comment' => '删除时间']) - ->addIndex(['unique_label'], ['unique' => true]) + ->addIndex(['at_platform', 'language_id', 'unique_label'], ['name' => 'idx_at_platform_language_id_unique_label', 'unique' => true]) ->create(); } } diff --git a/database/migrations/20241230095616_create_sys_banner.php b/database/migrations/20241230095616_create_sys_banner.php index 64bdfad9..d77d0855 100644 --- a/database/migrations/20241230095616_create_sys_banner.php +++ b/database/migrations/20241230095616_create_sys_banner.php @@ -31,7 +31,6 @@ class CreateSysBanner extends Migrator $table->addColumn('language_id', 'integer', ['null' => false, 'comment' => '语言ID']) ->addColumn('at_platform', 'string', ['limit' => 8, 'null' => false, 'comment' => '所在平台: pc为电脑, mobile为手机']) ->addColumn('at_page', 'string', ['limit' => 255, 'null' => true, 'comment' => '所在页面']) - ->addColumn('at_position', 'string', ['limit' => 255, 'null' => true, 'comment' => '所在位置: top为顶部, footer为底部, left为左侧, right为右侧, center为中间']) ->addColumn('unique_label', 'string', ['limit' => 64, 'null' => false, 'comment' => 'banner唯一标识']) ->addColumn('name', 'string', ['limit' => 64, 'null' => false, 'comment' => 'banner名称']) ->addColumn('desc', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => 'banner描述']) @@ -41,7 +40,7 @@ class CreateSysBanner extends Migrator ->addColumn('created_at', 'timestamp', ['null' => false, 'default' =>'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' =>'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间']) ->addColumn('deleted_at', 'timestamp', ['null' => true, 'default' => null, 'comment' => '删除时间']) - ->addIndex(['unique_label'], ['unique' => true]) + ->addIndex(['at_platform', 'language_id', 'unique_label'], ['name' => 'idx_at_platform_language_id_unique_label', 'unique' => true]) ->create(); } } diff --git a/database/seeds/AgentEnterpriseSizeTypeInit.php b/database/seeds/AgentEntrypriceSizeTypeInit.php similarity index 93% rename from database/seeds/AgentEnterpriseSizeTypeInit.php rename to database/seeds/AgentEntrypriceSizeTypeInit.php index c4d5e13f..eb240cfd 100644 --- a/database/seeds/AgentEnterpriseSizeTypeInit.php +++ b/database/seeds/AgentEntrypriceSizeTypeInit.php @@ -2,7 +2,7 @@ use think\migration\Seeder; -class AgentEnterpriseSizeTypeInit extends Seeder +class AgentEntrypriceSizeTypeInit extends Seeder { /** * Run Method. @@ -25,7 +25,7 @@ class AgentEnterpriseSizeTypeInit extends Seeder ["id" => 8, "language_id" => 2, "name" => "200 Or More", "value" => "200 Or More", "desc" => null, "sort" => 4, "created_at" => "2025-03-13 17:42:20"] ]; - $table = $this->table('agent_enterprise_size_type'); + $table = $this->table('agent_entryprice_size_type'); // empty the data $table->truncate(); diff --git a/database/seeds/ProductAttrInit.php b/database/seeds/ProductAttrInit.php new file mode 100644 index 00000000..2f2cd503 --- /dev/null +++ b/database/seeds/ProductAttrInit.php @@ -0,0 +1,30 @@ + 1, 'language_id' => 1, 'attr_type' => 1, 'attr_name' => '颜色', 'is_system' => 1, 'created_at' => '2025-02-12 10:11:05', 'updated_at' => '2025-03-28 16:17:46', 'deleted_at' => null], + ['id' => 2, 'language_id' => 2, 'attr_type' => 1, 'attr_name' => 'Color', 'is_system' => 1, 'created_at' => '2025-02-12 10:11:05', 'updated_at' => '2025-05-26 11:08:55', 'deleted_at' => null] + ]; + + $table = $this->table('product_attr'); + + // empty the table + $table->truncate(); + + // insert data + $table->insert($data)->saveData(); + } +} \ No newline at end of file