fix: column ui_schema_id does not exist

This commit is contained in:
chenos 2023-03-12 18:44:45 +08:00
parent 7313307210
commit 907eb72efc

View File

@ -4,16 +4,21 @@ import { FieldModel } from '../models';
export default class extends Migration { export default class extends Migration {
async up() { async up() {
const transaction = await this.db.sequelize.transaction(); const transaction = await this.db.sequelize.transaction();
const migrateFieldsSchema = async (collection: Collection) => { const migrateFieldsSchema = async (collection: Collection) => {
this.app.log.info(`Start to migrate ${collection.name} collection's ui schema`); this.app.log.info(`Start to migrate ${collection.name} collection's ui schema`);
collection.setField('uiSchemaUid', { const field = collection.setField('uiSchemaUid', {
type: 'string', type: 'string',
}); });
const exists = await field.existsInDb({ transaction });
if (!exists) {
return;
}
const fieldRecords: Array<FieldModel> = await collection.repository.find({ const fieldRecords: Array<FieldModel> = await collection.repository.find({
transaction, transaction,
}); });