fix: transaction cannot be rolled back because it has been finished

This commit is contained in:
chenos 2023-03-12 13:39:27 +08:00
parent 89284bb175
commit aece9015aa

View File

@ -1,6 +1,6 @@
import { Collection } from '@nocobase/database';
import { Migration } from '@nocobase/server';
import { FieldModel } from '../models';
import { Collection } from '@nocobase/database';
export default class extends Migration {
async up() {
@ -62,7 +62,6 @@ export default class extends Migration {
});
}
await transaction.commit();
collection.removeField('uiSchemaUid');
this.app.log.info('Migrate uiSchema to options field done');
};
@ -73,6 +72,8 @@ export default class extends Migration {
if (this.db.getCollection('fieldsHistory')) {
await migrateFieldsSchema(this.db.getCollection('fieldsHistory'));
}
await transaction.commit();
} catch (error) {
await transaction.rollback();
this.app.log.error(error);