Files
dafuweng/db/migrations/20231020071333_create_slider.php
2026-03-02 13:44:38 +08:00

39 lines
1.8 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
use Phinx\Db\Adapter\MysqlAdapter;
use Phinx\Migration\AbstractMigration;
final class CreateSlider extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$exists = $this->hasTable('slider');
if (!$exists) {
$table = $this->table('slider', ['comment' => '轮播图']);
$table->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'comment' => '部门/渠道id'])
->addColumn('url', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '超連結'])
->addColumn('content', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR, 'comment' => '內文'])
->addColumn('picture_url', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '圖片位置'])
->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1, 'comment' => '狀態0=停用, 1=啟用'])
->addColumn('sort', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'null' => false, 'default' => 0, 'comment' => '排序'])
->addColumn('created_at', 'timestamp', ['comment' => '创建时间'])
->addColumn('updated_at', 'timestamp', ['comment' => '更新时间'])
->addColumn('deleted_at', 'timestamp', ['comment' => '删除时间'])
->create();
}
}
}