fix(share-collection): sync plugins when install sub app (#2650)

This commit is contained in:
ChengLei Shao 2023-09-14 20:46:49 +08:00 committed by GitHub
parent 34b0ce06ba
commit dbe3af26a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,9 +95,17 @@ class SubAppPlugin extends Plugin {
// delete old collection // delete old collection
await subApp.db.sequelize.query(`TRUNCATE ${subAppPluginsCollection.quotedTableName()}`); await subApp.db.sequelize.query(`TRUNCATE ${subAppPluginsCollection.quotedTableName()}`);
const columnsInfo = await subApp.db.sequelize
.getQueryInterface()
.describeTable(subAppPluginsCollection.getTableNameWithSchema());
const columns = Object.keys(columnsInfo).sort();
const columnsInSql = columns.map((column) => `"${column}"`).join(', ');
await subApp.db.sequelize.query(` await subApp.db.sequelize.query(`
INSERT INTO ${subAppPluginsCollection.quotedTableName()} INSERT INTO ${subAppPluginsCollection.quotedTableName()} (${columnsInSql})
SELECT * SELECT ${columnsInSql}
FROM ${mainAppPluginsCollection.quotedTableName()} FROM ${mainAppPluginsCollection.quotedTableName()}
WHERE "name" not in ('multi-app-manager', 'multi-app-share-collection'); WHERE "name" not in ('multi-app-manager', 'multi-app-share-collection');
`); `);