Skip to content

Commit

Permalink
添加数据库迁移
Browse files Browse the repository at this point in the history
  • Loading branch information
doyouhaobaby committed Feb 17, 2023
1 parent cf9c768 commit 4dfc18f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions assets/database/migrations/20230217145516_base_brand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class BaseBrand extends AbstractMigration
{
public function up(): void
{
$this->struct();
$this->seed();
}

public function down(): void
{
$this->table('base_brand')->drop()->save();
}

private function struct(): void
{
$sql = <<<'EOT'
CREATE TABLE `base_brand` (
`brand_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`company_id` bigint(20) unsigned NOT NULL COMMENT '公司ID',
`status` enum('T','F') NOT NULL DEFAULT 'T' COMMENT '状态',
`order_num` bigint(20) unsigned NOT NULL DEFAULT '500' COMMENT '排序',
`brand_num` varchar(30) NOT NULL DEFAULT '' COMMENT '编号',
`brand_name` varchar(30) NOT NULL DEFAULT '' COMMENT '名称',
`brand_logo` varchar(130) NOT NULL DEFAULT '' COMMENT 'LOGO',
`brand_about` text NOT NULL COMMENT '介绍',
`update_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`brand_letter` varchar(30) NOT NULL DEFAULT '' COMMENT '品牌首字母',
`seo_keywords` varchar(30) NOT NULL COMMENT 'SEO关键字',
PRIMARY KEY (`brand_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
EOT;
$this->execute($sql);
}

private function seed(): void
{
/*
$sql = <<<'EOT'
EOT;
$this->execute($sql);
*/
}
}

0 comments on commit 4dfc18f

Please sign in to comment.