fix: migration error
This commit is contained in:
parent
427171342f
commit
1798170a9c
@ -1,5 +1,6 @@
|
||||
import { DataTypes } from '@nocobase/database';
|
||||
import { Migration } from '../migration';
|
||||
import { PluginManager } from '../plugin-manager';
|
||||
|
||||
export default class extends Migration {
|
||||
async up() {
|
||||
@ -12,12 +13,30 @@ export default class extends Migration {
|
||||
if (await field.existsInDb()) {
|
||||
return;
|
||||
}
|
||||
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, 'packageName', {
|
||||
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
|
||||
type: DataTypes.STRING,
|
||||
});
|
||||
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
||||
type: 'unique',
|
||||
fields: ['packageName'],
|
||||
fields: [field.columnName()],
|
||||
});
|
||||
const repository = this.db.getRepository<any>('applicationPlugins');
|
||||
const plugins = await repository.find();
|
||||
for (const plugin of plugins) {
|
||||
const { name } = plugin;
|
||||
if (plugin.packageName) {
|
||||
continue;
|
||||
}
|
||||
const packageName = PluginManager.getPackageName(name);
|
||||
await repository.update({
|
||||
filter: {
|
||||
name,
|
||||
},
|
||||
values: {
|
||||
packageName,
|
||||
},
|
||||
});
|
||||
console.log(name, packageName);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user