This commit is contained in:
你的名字
2025-10-15 14:53:54 +08:00
commit ac0f12b21a
864 changed files with 200931 additions and 0 deletions

View File

@ -0,0 +1,48 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class Articles 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(): void
{
$this->table('articles')->drop()->save();
$this->table('articles', ['comment' => '文章表'])
->addColumn('title', 'string', ['limit' => 50, 'null' => false, 'comment' => '分类名称'])
->addColumn('cate_id', 'integer', ['null' => false, 'comment' => '分类ID'])
->addColumn('cover', 'string', ['limit' => 255, 'null' => true, 'default' => '', 'comment' => '封面'])
->addColumn('summary', 'string', ['limit' => 255, 'null' => true, 'default' => '', 'comment' => '简介'])
->addColumn('content', 'text', ['null' => true, 'comment' => '内容'])
->addColumn('author', 'string', ['limit' => 50, 'null' => true, 'default' => '', 'comment' => '作者'])
->addColumn('sort', 'integer', ['default' => 0, 'null' => false, 'comment' => '排序'])
->addColumn('status', 'boolean', ['default' => 1, 'null' => false, 'comment' => '状态 1:启用 0:禁用'])
->addColumn('create_time', 'integer', ['null' => true, 'comment' => '创建时间'])
->addColumn('update_time', 'integer', ['null' => true, 'comment' => '更新时间'])
->addIndex(['title','cate_id'], ['unique' => true, 'name' => 'idx_title_cate_id'])
->addIndex(['status','sort'], ['name' => 'idx_status_sort'])
->addIndex(['create_time','sort'], ['name' => 'idx_create_time_sort'])
->save();
}
}