007_createSystemSettingsTable.ts 930 B

12345678910111213141516171819202122232425
  1. import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
  2. import { SystemSettingKey, SystemSettingGroup, ALLOWED_FILE_TYPES } from '../../client/share/types.ts'
  3. const createSystemSettingsTable: MigrationLiveDefinition = {
  4. name: "create_system_settings_table",
  5. up: async (api) => {
  6. await api.schema.createTable('system_settings', (table) => {
  7. table.increments('id').primary();
  8. table.string('key').notNullable().unique().comment('设置键');
  9. table.text('value').notNullable().comment('设置值');
  10. table.string('description').nullable().comment('设置描述');
  11. table.string('group').notNullable().comment('设置分组');
  12. table.timestamps(true, true);
  13. // 添加索引
  14. table.index('key');
  15. table.index('group');
  16. });
  17. },
  18. down: async (api) => {
  19. await api.schema.dropTable('system_settings');
  20. }
  21. }
  22. export default createSystemSettingsTable;