mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:47:10 +00:00
fix: migration error
This commit is contained in:
parent
aece9015aa
commit
cb97c7ae5c
@ -4,15 +4,6 @@ import { FieldModel } from '../models';
|
|||||||
|
|
||||||
export default class extends Migration {
|
export default class extends Migration {
|
||||||
async up() {
|
async up() {
|
||||||
const migratedFieldsCount = await this.db.getRepository('fields').count({
|
|
||||||
filter: {
|
|
||||||
'options.uiSchema': { $exists: true },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (migratedFieldsCount > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const transaction = await this.db.sequelize.transaction();
|
const transaction = await this.db.sequelize.transaction();
|
||||||
|
|
||||||
@ -53,6 +44,10 @@ export default class extends Migration {
|
|||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!uiSchemaRecord) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const uiSchema = uiSchemaRecord.get('schema');
|
const uiSchema = uiSchemaRecord.get('schema');
|
||||||
|
|
||||||
fieldRecord.set('uiSchema', uiSchema);
|
fieldRecord.set('uiSchema', uiSchema);
|
||||||
@ -68,11 +63,9 @@ export default class extends Migration {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await migrateFieldsSchema(this.db.getCollection('fields'));
|
await migrateFieldsSchema(this.db.getCollection('fields'));
|
||||||
|
|
||||||
if (this.db.getCollection('fieldsHistory')) {
|
if (this.db.getCollection('fieldsHistory')) {
|
||||||
await migrateFieldsSchema(this.db.getCollection('fieldsHistory'));
|
await migrateFieldsSchema(this.db.getCollection('fieldsHistory'));
|
||||||
}
|
}
|
||||||
|
|
||||||
await transaction.commit();
|
await transaction.commit();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await transaction.rollback();
|
await transaction.rollback();
|
Loading…
Reference in New Issue
Block a user