20211117030202_create_rice_card_table.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class CreateRiceCardTable 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. $table = $this->table('rice_card',array('id' => true,'primary_key' => ['id'],'engine'=>'InnoDB','comment'=>'米卡表'));
  30. $table->addColumn('type', 'integer',array('limit' => 2,'signed'=>false,'default'=>0,'comment'=>'米卡类型 1-电子套餐卡 2-电子现金卡 3-电子实物兑换卡'))
  31. ->addColumn('name', 'string',array('limit' => 255,'default'=>'','comment'=>'米卡名称'))
  32. ->addColumn('image_id', 'integer',array('limit' => 11,'signed'=>false,'default'=>0,'comment'=>'米卡图'))
  33. ->addColumn('expire_day', 'integer',array('limit' => 11,'signed'=>false,'default'=>0,'comment'=>'有效天数'))
  34. ->addColumn('stock', 'integer',array('limit' => 11,'signed'=>false,'default'=>0,'comment'=>'库存'))
  35. ->addColumn('sale_num', 'integer',array('limit' => 11,'signed'=>false,'default'=>0,'comment'=>'销量'))
  36. ->addColumn('card_price', 'decimal',array('limit' => 11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'售价'))
  37. ->addColumn('dk_cat_ids', 'string',array('limit' => 255,'default'=>'','comment'=>'抵扣商品类目 默认空 空表示所有类目 多个类目id以逗号分隔'))
  38. ->addColumn('describe', 'text',array('null' => true, 'comment'=>'米卡说明'))
  39. ->addColumn('content', 'text',array('null' => true, 'comment'=>'米卡详情'))
  40. ->addColumn('status', 'integer',array('limit' => 2,'signed'=>false,'default'=>0,'comment'=>'米卡状态 默认0 0-下架 1-上架'))
  41. ->addColumn('is_delete', 'integer',array('limit' => 1,'signed'=>false,'default'=>0,'comment'=>'删除状态 0-未删除 1-已删除'))
  42. ->addColumn('create_time', 'datetime',array('null' => true,'comment'=>'创建时间'))
  43. ->addColumn('update_time', 'datetime',array('null' => true,'comment'=>'更新时间'))
  44. ->create();
  45. }
  46. }