20251010100200_create_shipping_template_relations_table.php 848 B

12345678910111213141516171819202122
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class CreateShippingTemplateRelationsTable extends Migrator
  5. {
  6. public function change()
  7. {
  8. $table = $this->table('shipping_template_relations');
  9. $table->setId('id')
  10. ->addColumn('template_id', 'integer', ['comment' => '运费模板ID'])
  11. ->addColumn('biz_type', 'string', ['limit' => 50, 'comment' => '业务类型: goods(商品), category(商品分类), shop(店铺)等'])
  12. ->addColumn('biz_id', 'integer', ['comment' => '业务实体ID'])
  13. ->addTimestamps('create_time', 'update_time')
  14. ->addIndex(['template_id'])
  15. ->addIndex(['biz_type'])
  16. ->addIndex(['biz_id'])
  17. ->addIndex(['template_id', 'biz_type', 'biz_id'], ['unique' => true])
  18. ->create();
  19. }
  20. }