fix: migration error
This commit is contained in:
parent
427171342f
commit
1798170a9c
@ -1,5 +1,6 @@
|
|||||||
import { DataTypes } from '@nocobase/database';
|
import { DataTypes } from '@nocobase/database';
|
||||||
import { Migration } from '../migration';
|
import { Migration } from '../migration';
|
||||||
|
import { PluginManager } from '../plugin-manager';
|
||||||
|
|
||||||
export default class extends Migration {
|
export default class extends Migration {
|
||||||
async up() {
|
async up() {
|
||||||
@ -12,12 +13,30 @@ export default class extends Migration {
|
|||||||
if (await field.existsInDb()) {
|
if (await field.existsInDb()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, 'packageName', {
|
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
});
|
});
|
||||||
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
||||||
type: 'unique',
|
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