20250830123540_user_point.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. class UserPoint extends AbstractMigration
  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(): void
  28. {
  29. // 用户积分表
  30. $table = $this->table('extension_user_point',[
  31. 'collation' => 'utf8mb4_unicode_ci',
  32. 'id' => false,
  33. 'comment' => '用户积分表',
  34. ]);
  35. $table->addColumn('user_id', 'integer', ['signed' => false, 'comment' => '用户ID'])
  36. ->addColumn('point', 'integer', ['signed' => true, 'default' => 0, 'comment' => '积分'])
  37. ->addColumn('freeze_point', 'integer', ['signed' => true, 'default' => 0, 'comment' => '冻结积分'])
  38. ->addTimestamps('create_time', 'update_time')
  39. ->create();
  40. }
  41. }