fix: skip migration if exists (#3439)

This commit is contained in:
chenos 2024-01-26 09:31:28 +08:00 committed by GitHub
parent 2c90c0c6c3
commit d692d9cf1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,6 +8,11 @@ export default class extends Migration {
async up() {
const tableNameWithSchema = this.pm.collection.getTableNameWithSchema();
const field = this.pm.collection.getField('packageName');
const exists = await field.existsInDb();
if (exists) {
return;
}
try {
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
type: DataTypes.STRING,
});
@ -15,5 +20,8 @@ export default class extends Migration {
type: 'unique',
fields: [field.columnName()],
});
} catch (error) {
//
}
}
}