20250624125157_extension_config.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. use think\migration\Migrator;
  3. class ExtensionConfig extends Migrator
  4. {
  5. /**
  6. * Change Method.
  7. */
  8. public function change(): void
  9. {
  10. $table = $this->table('extension_config', [
  11. 'id' => false,
  12. 'primary_key' => 'id'
  13. ]);
  14. $table->addColumn('id', 'integer', [
  15. 'identity' => true,
  16. 'signed' => false,
  17. 'comment' => '主键'
  18. ])
  19. ->addColumn('extension_id', 'string', [
  20. 'limit' => 32,
  21. 'comment' => '模块ID,关联extension表'
  22. ])
  23. ->addColumn('key', 'string', [
  24. 'limit' => 64,
  25. 'comment' => '配置项名称'
  26. ])
  27. ->addColumn('value', 'json', [
  28. 'null' => true,
  29. 'comment' => '配置值,JSON格式存储'
  30. ])
  31. ->addColumn('type', 'string', [
  32. 'limit' => 32,
  33. 'default' => 'text',
  34. 'comment' => '配置类型:input, radio, select等'
  35. ])
  36. ->addColumn('title', 'string', [
  37. 'limit' => 32,
  38. 'default' => 'text',
  39. 'comment' => '配置名称'
  40. ])
  41. ->addColumn('create_time', 'timestamp', [
  42. 'default' => 'CURRENT_TIMESTAMP',
  43. 'comment' => '创建时间'
  44. ])
  45. ->addColumn('update_time', 'timestamp', [
  46. 'default' => 'CURRENT_TIMESTAMP',
  47. 'update' => 'CURRENT_TIMESTAMP',
  48. 'comment' => '更新时间'
  49. ])
  50. ->addIndex(['extension_id'], ['name' => 'extension_id'])
  51. ->addIndex(['extension_id', 'key'], ['unique' => true, 'name' => 'uniq_extension_id_key']) // 复合唯一索引
  52. ->create();
  53. }
  54. }