fix: transaction error (#1162)
This commit is contained in:
parent
7cfa939f63
commit
dea9655573
@ -90,20 +90,29 @@ export class SyncRunner {
|
|||||||
const sequenceTables = [...parentsDeep, tableName];
|
const sequenceTables = [...parentsDeep, tableName];
|
||||||
|
|
||||||
for (const sequenceTable of sequenceTables) {
|
for (const sequenceTable of sequenceTables) {
|
||||||
try {
|
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,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (idColumnQuery[0].length == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
await queryInterface.sequelize.query(
|
await queryInterface.sequelize.query(
|
||||||
`alter table "${sequenceTable}" alter column id set default nextval('${maxSequenceName}')`,
|
`alter table "${sequenceTable}" alter column id set default nextval('${maxSequenceName}')`,
|
||||||
{
|
{
|
||||||
transaction,
|
transaction,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (err) {
|
|
||||||
if (err.message.match(/column "id" of relation "\w+" does not exist/)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit cf44c47ff9b5ef41e8becde3f1c8b5b1c2af6cda
|
Subproject commit 5a5fba41ae1cecaf3b073fcb610e9dc68dad0b85
|
Loading…
Reference in New Issue
Block a user