20250710063222_extension_auth_permission.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. use think\migration\Migrator;
  3. class ExtensionAuthPermission extends Migrator
  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_auth_permission', [
  29. 'engine' => 'InnoDB',
  30. 'collation' => 'utf8mb4_general_ci',
  31. 'comment' => '权限表',
  32. ]);
  33. $table
  34. ->addColumn('name', 'string', [
  35. 'limit' => 255,
  36. 'default' => '',
  37. 'comment' => '权限名称',
  38. ])
  39. ->addColumn('rule', 'string', [
  40. 'limit' => 50,
  41. 'default' => '',
  42. 'comment' => '权限规则',
  43. ])
  44. ->addColumn('route', 'string', [
  45. 'limit' => 255,
  46. 'default' => '',
  47. 'comment' => '权限路由',
  48. ])
  49. ->addColumn('method', 'string', [
  50. 'limit' => 50,
  51. 'default' => '',
  52. 'comment' => '权限方法',
  53. ])
  54. ->addColumn('description', 'string', [
  55. 'limit' => 255,
  56. 'default' => '',
  57. 'comment' => '权限描述',
  58. ])
  59. ->addTimestamps()
  60. ->addIndex('route', ['unique' => true, 'name' => 'uniq_route'])
  61. ->create();
  62. }
  63. }