fix: skip migration if exists (#3439)
This commit is contained in:
parent
2c90c0c6c3
commit
d692d9cf1b
@ -8,12 +8,20 @@ export default class extends Migration {
|
|||||||
async up() {
|
async up() {
|
||||||
const tableNameWithSchema = this.pm.collection.getTableNameWithSchema();
|
const tableNameWithSchema = this.pm.collection.getTableNameWithSchema();
|
||||||
const field = this.pm.collection.getField('packageName');
|
const field = this.pm.collection.getField('packageName');
|
||||||
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
|
const exists = await field.existsInDb();
|
||||||
type: DataTypes.STRING,
|
if (exists) {
|
||||||
});
|
return;
|
||||||
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
}
|
||||||
type: 'unique',
|
try {
|
||||||
fields: [field.columnName()],
|
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
|
||||||
});
|
type: DataTypes.STRING,
|
||||||
|
});
|
||||||
|
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
||||||
|
type: 'unique',
|
||||||
|
fields: [field.columnName()],
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
//
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user