44 lines
2.5 KiB
PHP
44 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Db\Adapter\MysqlAdapter;
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateAdminFileAttachments 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('admin_file_attachments');
|
|
if (!$exists) {
|
|
$table = $this->table('admin_file_attachments', ['comment' => '系统附件分类']);
|
|
$table->addColumn('cate_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'signed' => false, 'null' => false, 'default' => 0, 'comment' => '分类id'])
|
|
->addColumn('uploader_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR, 'signed' => false, 'null' => false, 'default' => 0, 'comment' => '上传人id'])
|
|
->addColumn('type', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => 'image图片 file文件'])
|
|
->addColumn('file_type', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '文件类型'])
|
|
->addColumn('name', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '附件名称'])
|
|
->addColumn('real_name', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '原始文件名'])
|
|
->addColumn('path', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '路径'])
|
|
->addColumn('url', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '访问url'])
|
|
->addColumn('ext', 'string', ['limit' => 10, 'null' => false, 'default' => '', 'comment' => '文件后缀'])
|
|
->addColumn('disk', 'string', ['limit' => 20, 'null' => false, 'default' => '', 'comment' => 'disk'])
|
|
->addColumn('size', 'integer', ['limit' => MysqlAdapter::INT_BIG, 'null' => false, 'default' => 0, 'comment' => '文件大小'])
|
|
->addColumn('created_at', 'datetime', ['comment' => '创建时间'])
|
|
->addColumn('updated_at', 'datetime', ['comment' => '更新时间'])
|
|
->addColumn('deleted_at', 'datetime', ['comment' => '删除时间'])
|
|
->create();
|
|
}
|
|
}
|
|
}
|