20250830132345_user_point_log.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use Phinx\Migration\AbstractMigration;
  3. class UserPointLog extends AbstractMigration
  4. {
  5. /**
  6. * Change Method.
  7. *
  8. * Write your reversible migrations using this method.
  9. *
  10. * More information on writing migrations is available here:
  11. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  12. *
  13. * The following commands can be used in this method and Phinx will
  14. * automatically reverse them when rolling back:
  15. *
  16. * createTable
  17. * renameTable
  18. * addColumn
  19. * renameColumn
  20. * addIndex
  21. * addForeignKey
  22. *
  23. * Remember to call "create()" or "update()" and NOT "save()" when working
  24. * with the Table class.
  25. */
  26. public function change()
  27. {
  28. // 用户积分日志表
  29. $table = $this->table('extension_user_point_log', [
  30. 'collation' => 'utf8mb4_unicode_ci',
  31. 'comment' => '用户积分日志表',
  32. ]);
  33. $table->addColumn('user_id', 'integer', ['signed' => false, 'comment' => '用户ID'])
  34. ->addColumn('point', 'integer', ['signed' => true, 'default' => 0, 'comment' => '积分'])
  35. ->addColumn('freeze_point', 'integer', ['signed' => true, 'default' => 0, 'comment' => '冻结积分'])
  36. ->addColumn('after_point', 'integer', ['signed' => true, 'default' => 0, 'comment' => '变动后积分余额'])
  37. ->addColumn('after_freeze_point', 'integer', ['signed' => true, 'default' => 0, 'comment' => '变动后冻结积分余额'])
  38. ->addColumn('type', 'integer', ['signed' => false, 'default' => 0, 'comment' => '类型 1 新增 2 减少 3 对冲'])
  39. ->addColumn('biz_type', 'tinyinteger', ['signed' => false, 'default' => 0, 'comment' => '关联业务类型 1 订单 2 手动调整'])
  40. ->addColumn('biz_id', 'integer', ['signed' => false, 'default' => 0, 'comment' => '关联业务ID'])
  41. ->addColumn('remark', 'string', ['default' => '', 'comment' => '备注'])
  42. ->addTimestamps()
  43. ->addIndex('user_id')
  44. ->create();
  45. }
  46. }