20250627061219_extension.php 3.1 KB

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