20250624125157_extension_config.php 1.9 KB

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