refactor: 修改系统配置数据表迁移文件

This commit is contained in:
2024-12-30 16:20:19 +08:00
parent 8b25bf878e
commit 7f2ddeef57
3 changed files with 82 additions and 65 deletions

View File

@@ -0,0 +1,43 @@
<?php
use think\migration\Migrator;
class CreateSysConfig extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('sys_config', ['engine' => 'InnoDB', 'comment' => '系统配置表']);
$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' => 255, 'null' => false, 'comment' => '配置值'])
->addColumn('extra', 'string', ['limit' => 255, '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' => '更新时间'])
->create();
}
}

View File

@@ -1,65 +0,0 @@
<?php
use Phinx\Db\Adapter\MysqlAdapter;
use think\migration\Migrator;
class CreateSysSetting extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('sys_setting', ['engine' => 'InnoDB', 'comment' => '系统设置表']);
$table->addColumn('language_id', 'integer', ['null' => false, 'comment' => '语言ID'])
->addColumn('title', 'string', ['limit' => 128, 'default' => '', 'comment' => '站点标题'])
->addColumn('logo', 'string', ['limit' => 255, 'default' => '', 'comment' => '站点logo'])
->addColumn('keywords', 'string', ['limit' => 255, 'default' => '', 'comment' => '搜索引擎关键字'])
->addColumn('icp', 'string', ['limit' => 128, 'default' => '', 'comment' => '站点备案号'])
->addColumn('copyright', 'string', ['limit' => 128, 'default' => '', 'comment' => '站点版本信息'])
->addColumn('statistics_code', 'boolean', ['limit' => 255, 'default' => 1, 'comment' => '站点统计代码'])
->addColumn('tel', 'string', ['limit' => 64, 'default' => '', 'comment' => '固定电话'])
->addColumn('email', 'string', ['limit' => 128, 'default' => '', 'comment' => '邮箱'])
->addColumn('paginate_size', 'integer', ['limit' => 11, 'default' => 10, 'comment' => '分页大小'])
->addColumn('aliyun_sms_access_id', 'string', ['limit' => 128, 'default' => '', 'comment' => '阿里云短信AccessId'])
->addColumn('aliyun_sms_access_key', 'string', ['limit' => 128, 'default' => '', 'comment' => '阿里云短信AccessKey'])
->addColumn('aliyun_sms_sign_name', 'string', ['limit' => 128, 'default' => '', 'comment' => '阿里云短信签名'])
->addColumn('aliyun_sms_template_code', 'string', ['limit' => 128, 'default' => '', 'comment' => '阿里云短信模板'])
->addColumn('email_smtp_host', 'string', ['limit' => 128, 'default' => '', 'comment' => 'SMTP服务器'])
->addColumn('email_smtp_port', 'integer', ['limit' => 11, 'default' => 25, 'comment' => 'SMTP端口'])
->addColumn('email_smtp_user', 'string', ['limit' => 128, 'default' => '', 'comment' => 'SMTP用户名'])
->addColumn('email_smtp_password', 'string', ['limit' => 128, 'default' => '', 'comment' => 'SMTP密码'])
->addColumn('email_smtp_secure', 'string', ['limit' => 128, 'default' => '', 'comment' => 'SMTP加密'])
->addColumn('email_from', 'string', ['limit' => 128, 'default' => '', 'comment' => '发件人邮箱'])
->addColumn('enabled_watermark', 'boolean', ['null' => false, 'default' => 0, 'comment' => '是否启用水印'])
->addColumn('watermark_type', 'boolean', ['null' => false, 'default' => 1, 'comment' => '水印类型:1为文字,2为图片'])
->addColumn('watermark_text', 'string', ['limit' => 128, 'default' => '', 'comment' => '水印文字'])
->addColumn('watermark_image', 'string', ['limit' => 255, 'default' => '', 'comment' => '水印图片'])
->addColumn('watermark_width', 'integer', ['limit' => 11, 'default' => 100, 'comment' => '水印宽度'])
->addColumn('watermark_height', 'integer', ['limit' => 11, 'default' => 100, 'comment' => '水印高度'])
->addColumn('watermark_opacity', 'integer', ['limit' => 11, 'default' => 100, 'comment' => '水印透明度'])
->addColumn('watermark_quality', 'integer', ['limit' => 11, 'default' => 10, 'comment' => 'JPEG水印质量'])
->addColumn('watermark_position', MysqlAdapter::PHINX_TYPE_TINY_INTEGER, ['null' => true, 'default' => null, 'comment' => '水印位置:1为左上,2为上中,3为右上,4为左中,5为中间,6为右中,7为左下,8为下中,9为右下'])
->addColumn('created_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
->addColumn('updated_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间'])
->create();
}
}

View File

@@ -0,0 +1,39 @@
<?php
use think\migration\Migrator;
class CreateSysConfigGroup extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('sys_config_group', ['engine' => 'InnoDB', 'comment' => '系统配置分组表']);
$table->addColumn('language_id', 'integer', ['null' => false, 'comment' => '语言ID'])
->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' => '更新时间'])
->create();
}
}