20251010100000_create_shipping_templates_table.php 1.1 KB

123456789101112131415161718192021222324
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class CreateShippingTemplatesTable extends Migrator
  5. {
  6. public function change()
  7. {
  8. $table = $this->table('shipping_templates');
  9. $table->setId('id')
  10. ->addColumn('name', 'string', ['limit' => 100, 'comment' => '模板名称'])
  11. ->addColumn('calc_method', 'string', ['limit' => 20, 'comment' => '计费方式: piece(按件), weight(按重量), volume(按体积)'])
  12. ->addColumn('unit', 'string', ['limit' => 10, 'comment' => '单位: 件,g,kg,cm3,m3', 'default' => 'piece'])
  13. ->addColumn('status', 'integer', ['limit' => 1, 'comment' => '状态: 0(禁用), 1(启用)', 'default' => 1])
  14. ->addColumn('sort', 'integer', ['comment' => '排序', 'default' => 100])
  15. ->addTimestamps('create_time', 'update_time')
  16. ->addColumn('delete_time', 'timestamp', ['comment' => '删除时间', 'null' => true])
  17. ->addIndex(['name'])
  18. ->addIndex(['status'])
  19. ->addIndex(['sort'])
  20. ->create();
  21. }
  22. }