20250627061219_extension.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. class Extension 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()
  28. {
  29. $table = $this->table('extension', [
  30. 'comment' => '扩展管理表',
  31. 'engine' => 'InnoDB',
  32. 'collation' => 'utf8mb4_general_ci',
  33. 'id' => false,
  34. 'primary_key' => 'id'
  35. ]);
  36. $table->addColumn('id', 'string', [
  37. 'limit' => 50,
  38. 'null' => false,
  39. 'comment' => '扩展唯一标识符'
  40. ])->addColumn('name', 'string', [
  41. 'limit' => 100,
  42. 'null' => false,
  43. 'comment' => '扩展名称'
  44. ])->addColumn('is_core', 'boolean', [
  45. 'default' => false,
  46. 'comment' => '是否核心扩展'
  47. ])->addColumn('description', 'text', [
  48. 'null' => true,
  49. 'comment' => '扩展描述'
  50. ])->addColumn('version', 'string', [
  51. 'limit' => 20,
  52. 'null' => false,
  53. 'default' => '1.0.0',
  54. 'comment' => '扩展版本'
  55. ])->addColumn('core_version', 'string', [
  56. 'limit' => 20,
  57. 'null' => false,
  58. 'comment' => '支持的核心版本'
  59. ])->addColumn('author', 'string', [
  60. 'limit' => 100,
  61. 'null' => false,
  62. 'comment' => '作者'
  63. ])->addColumn('email', 'string', [
  64. 'limit' => 100,
  65. 'null' => true,
  66. 'comment' => '作者邮箱'
  67. ])->addColumn('website', 'string', [
  68. 'limit' => 255,
  69. 'null' => true,
  70. 'comment' => '扩展地址'
  71. ])->addColumn('image', 'string', [
  72. 'limit' => 255,
  73. 'null' => true,
  74. 'comment' => '扩展图片地址'
  75. ])->addColumn('license', 'string', [
  76. 'limit' => 50,
  77. 'null' => true,
  78. 'comment' => '开源协议'
  79. ])->addColumn('status', 'integer', [
  80. 'limit' => 1,
  81. 'default' => 0,
  82. 'comment' => '状态(1:未安装,2:安装,3:启用,4:禁用)'
  83. ])->addColumn('create_time', 'datetime', [
  84. 'null' => true,
  85. 'comment' => '创建时间'
  86. ])->addColumn('update_time', 'datetime', [
  87. 'null' => true,
  88. 'comment' => '更新时间'
  89. ])->addColumn('delete_time', 'datetime', [
  90. 'null' => true,
  91. 'comment' => '删除时间'
  92. ])->addIndex(['id'], [
  93. 'unique' => true,
  94. 'name' => 'uniq_id'
  95. ])->create();
  96. }
  97. }