tachybase_todo/packages/plugins/system-settings/src/migrations/20220714204714-update-enabled-languages.ts

18 lines
632 B
TypeScript
Raw Normal View History

import { Migration } from '@nocobase/server';
export default class UpdateEnabledLanguagesMigration extends Migration {
async up() {
const result = await this.app.version.satisfies('<=0.7.2-alpha.7');
if (!result) {
return;
}
const SystemSetting = this.context.db.getRepository('systemSettings');
const setting = await SystemSetting.findOne();
const enabledLanguages = setting.get('enabledLanguages') || [];
if (Array.isArray(enabledLanguages) && enabledLanguages.length === 0) {
setting.set('enabledLanguages', [setting.get('appLang') || 'en-US']);
await setting.save();
}
}
}