Files
CompanyProject/滴滴淘/diditao/database/migrations/20200510031324_upload_hash.php
2024-09-27 01:32:49 +08:00

52 lines
2.1 KiB
PHP

<?php
use think\migration\Migrator;
use think\migration\db\Column;
class UploadHash 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('upload_hash')->setCollation('utf8mb4_general_ci')->setComment('图片上传记录表');
$table
->addColumn(Column::string('save_path')->setComment('本地保存路径'))
->addColumn(Column::string('local_path')->setComment('本地保存路径'))
->addColumn(Column::string('file_name')->setComment('压缩后的图片名称'))
->addColumn(Column::string('origin_name')->setComment('原始图片名称'))
->addColumn(Column::string('water_name')->setComment('带水印的图片名')->setNullable())
->addColumn(Column::tinyInteger('oss_id')->setComment('ossId')->setDefault(1))
->addColumn(Column::tinyInteger('oss_path')->setComment('oss是否上传')->setDefault(0))
->addColumn(Column::char('file_sha1',50)->setComment('文件sha1'))
->addColumn(Column::char('extension',40)->setComment('文件后缀'))
->addColumn(Column::unsignedInteger('file_size')->setComment('文件大小'))
->addColumn(Column::unsignedInteger("create_time")->setComment('创建时间'))
->addColumn(Column::unsignedInteger("update_time")->setComment('更新时间'))
->addIndex(['local_path'])
->addIndex(['file_sha1'])
->addIndex(['extension'])
->addIndex(['file_size'])
->create();
}
}