fix(plugin-workflow): fix migration (#2927)

This commit is contained in:
Junyi 2023-10-27 21:14:56 +08:00 committed by GitHub
parent 6f3681c2aa
commit 4bac9abbbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,11 +28,12 @@ export default class extends Migration {
} }
const { db } = this.context; const { db } = this.context;
const NodeRepo = db.getRepository('flow_nodes'); const NodeCollection = db.getCollection('flow_nodes');
const { key } = await this.queryInterface.describeTable('flow_nodes'); const NodeRepo = NodeCollection.repository;
const tableName = NodeCollection.getTableNameWithSchema();
await db.sequelize.transaction(async (transaction) => { await db.sequelize.transaction(async (transaction) => {
if (!key) { if (!(await NodeCollection.getField('key').existsInDb())) {
await this.queryInterface.addColumn('flow_nodes', 'key', DataTypes.STRING, { await this.queryInterface.addColumn(tableName, 'key', DataTypes.STRING, {
transaction, transaction,
}); });
} }