20260525090001_create_currency.php 1.2 KB

123456789101112131415161718192021222324252627
  1. <?php
  2. use Phinx\Db\Adapter\MysqlAdapter;
  3. use think\migration\Migrator;
  4. class CreateCurrency extends Migrator
  5. {
  6. public function change(): void {
  7. $table = $this->table('currency', [
  8. 'id' => 'id',
  9. 'engine' => 'InnoDB',
  10. 'collation' => 'utf8mb4_general_ci',
  11. 'comment' => '币种字典表',
  12. 'auto_id' => true,
  13. ]);
  14. $table
  15. ->addColumn('code', 'string', ['limit' => 8, 'null' => false, 'default' => '', 'comment' => '币种代码(ISO 4217,业务唯一键)'])
  16. ->addColumn('title', 'string', ['limit' => 50, 'null' => false, 'default' => '', 'comment' => '币种名称'])
  17. ->addColumn('sort', 'integer', ['null' => false, 'default' => 0, 'comment' => '排序'])
  18. ->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1, 'comment' => '状态:0禁用,1启用'])
  19. ->addColumn('create_time', 'biginteger', ['null' => false, 'default' => 0, 'comment' => '创建时间'])
  20. ->addColumn('delete_time', 'biginteger', ['null' => false, 'default' => 0, 'comment' => '删除时间'])
  21. ->addIndex(['code'], ['name' => 'idx_code'])
  22. ->create();
  23. }
  24. }