mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:17:23 +00:00
fix: transaction error (#1162)
This commit is contained in:
parent
7cfa939f63
commit
dea9655573
@ -90,20 +90,29 @@ export class SyncRunner {
|
||||
const sequenceTables = [...parentsDeep, tableName];
|
||||
|
||||
for (const sequenceTable of sequenceTables) {
|
||||
try {
|
||||
await queryInterface.sequelize.query(
|
||||
`alter table "${sequenceTable}" alter column id set default nextval('${maxSequenceName}')`,
|
||||
{
|
||||
transaction,
|
||||
},
|
||||
);
|
||||
} catch (err) {
|
||||
if (err.message.match(/column "id" of relation "\w+" does not exist/)) {
|
||||
continue;
|
||||
}
|
||||
const idColumnQuery = await queryInterface.sequelize.query(
|
||||
`
|
||||
SELECT true
|
||||
FROM pg_attribute
|
||||
WHERE attrelid = '${sequenceTable}'::regclass -- cast to a registered class (table)
|
||||
AND attname = 'id'
|
||||
AND NOT attisdropped
|
||||
`,
|
||||
{
|
||||
transaction,
|
||||
},
|
||||
);
|
||||
|
||||
throw err;
|
||||
if (idColumnQuery[0].length == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
await queryInterface.sequelize.query(
|
||||
`alter table "${sequenceTable}" alter column id set default nextval('${maxSequenceName}')`,
|
||||
{
|
||||
transaction,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit cf44c47ff9b5ef41e8becde3f1c8b5b1c2af6cda
|
||||
Subproject commit 5a5fba41ae1cecaf3b073fcb610e9dc68dad0b85
|
Loading…
Reference in New Issue
Block a user