20220705020220_create_ms_activity_good_table.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class CreateMsActivityGoodTable extends Migrator
  5. {
  6. /**
  7. * Change Method.
  8. *
  9. * Write your reversible migrations using this method.
  10. *
  11. * More information on writing migrations is available here:
  12. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  13. *
  14. * The following commands can be used in this method and Phinx will
  15. * automatically reverse them when rolling back:
  16. *
  17. * createTable
  18. * renameTable
  19. * addColumn
  20. * renameColumn
  21. * addIndex
  22. * addForeignKey
  23. *
  24. * Remember to call "create()" or "update()" and NOT "save()" when working
  25. * with the Table class.
  26. */
  27. public function change()
  28. {
  29. $this->table('ms_activity_goods', array('id' => true, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'comment' => '秒杀商品表'))
  30. ->addColumn('ms_activity_id', 'integer', array('limit' => 11, 'signed' => false, 'default' => 0, 'comment' => '秒杀活动ID'))
  31. ->addColumn('goods_id', 'integer',array('limit' => 10, 'signed' => false, 'default'=> 0,'comment'=>'商品ID'))
  32. ->addColumn('goods_sku_id', 'integer',array('limit' => 10, 'signed' => false, 'default'=> 0,'comment'=>'商品SKU'))
  33. ->addColumn('goods_sku_no', 'string',array('limit' => 50,'default'=>'','comment'=>'商品SKU编码'))
  34. ->addColumn('goods_name', 'string',array('limit' => 255,'default'=>'','comment'=>'商品名称'))
  35. ->addColumn('preview_url', 'string',array('limit' => 255,'default'=>'','comment'=>'商品图片'))
  36. ->addColumn('goods_price', 'decimal',array('limit' => 11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'商品售价'))
  37. ->addColumn('ms_price', 'decimal',array('limit' => 11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'秒杀价'))
  38. ->addColumn('start_time', 'datetime',array('null' => true,'comment'=>'秒杀开始时间'))
  39. ->addColumn('end_time', 'datetime',array('null' => true,'comment'=>'秒杀结束时间'))
  40. ->addColumn('limit_mount', 'integer',array('limit' => 10, 'signed' => false, 'default'=> 0,'comment'=>'限购件数'))
  41. ->addColumn('stock_num', 'integer',array('limit' => 10, 'signed' => false, 'default'=> 0,'comment'=>'活动商品库存'))
  42. ->addColumn('sale_num', 'integer',array('limit' => 10, 'signed' => false, 'default'=> 0,'comment'=>'活动商品销量'))
  43. ->addColumn('ms_sale_sum_price', 'decimal',array('limit' => 11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'活动总销售金额'))
  44. ->addColumn('is_delete', 'integer',array('limit' => 4, 'signed' => false, 'default'=> 0,'comment'=>'删除0:可用,1:禁用'))
  45. ->addColumn('create_time', 'integer', array('limit' => 10,'signed' => false, 'default' => 0, 'comment' => '创建时间'))
  46. ->addColumn('update_time', 'integer', array('limit' => 10,'signed' => false, 'default' => 0, 'comment' => '更新时间'))
  47. ->create();
  48. }
  49. }