20250709013140_extension_wechat_user.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. use Phinx\Migration\AbstractMigration;
  3. class ExtensionWechatUser 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(): void
  27. {
  28. $table = $this->table('extension_wechat_user', ['engine' => 'InnoDB', 'comment' => '微信用户表']);
  29. $table
  30. ->addColumn('user_id', 'integer', ['signed' => false, 'comment' => '用户ID'])
  31. ->addColumn('openid', 'string', ['comment' => '微信openid'])
  32. ->addColumn('appid', 'string', ['comment' => '微信appid'])
  33. ->addColumn('nickname', 'string', ['comment' => '昵称'])
  34. ->addColumn('avatar', 'string', ['comment' => '头像'])
  35. ->addTimestamps('create_time', 'update_time')
  36. ->addColumn('delete_time', 'timestamp', ['null' => true, 'default' => null])
  37. ->create();
  38. }
  39. }