20250830132345_user_point_log.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class UserPointLog 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. // 用户积分日志表
  30. $table = $this->table('extension_user_point_log',[
  31. 'collation' => 'utf8mb4_unicode_ci',
  32. 'comment' => '用户积分日志表',
  33. ]);
  34. $table->addColumn('user_id', Column::INTEGER, ['signed' => false, 'comment' => '用户ID'])
  35. ->addColumn('point', Column::INTEGER, ['signed' => true, 'default' => 0, 'comment' => '积分'])
  36. ->addColumn('freeze_point', Column::INTEGER, ['signed' => true, 'default' => 0, 'comment' => '冻结积分'])
  37. ->addColumn('after_point', Column::INTEGER, ['signed' => true, 'default' => 0, 'comment' => '变动后积分余额'])
  38. ->addColumn('after_freeze_point', Column::INTEGER, ['signed' => true, 'default' => 0, 'comment' => '变动后冻结积分余额'])
  39. ->addColumn('type', Column::INTEGER, ['signed' => false, 'default' => 0, 'comment' => '类型 1 新增 2 减少 3 对冲'])
  40. ->addColumn('biz_type', Column::TINYINTEGER, ['signed' => false, 'default' => 0, 'comment' => '关联业务类型 1 订单'])
  41. ->addColumn('biz_id', Column::INTEGER, ['signed' => false, 'default' => 0, 'comment' => '关联业务ID'])
  42. ->addColumn('remark', Column::STRING, ['default' => '', 'comment' => '备注'])
  43. ->addTimestamps()
  44. ->addIndex('user_id')
  45. ->create();
  46. }
  47. }