20250710063222_extension_auth_permission.php 2.0 KB

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