mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
fix(core): Metadata inserts using existing IDs and failing with postgres (#10108)
This commit is contained in:
@@ -108,5 +108,15 @@ export class AddConstraintToExecutionMetadata1720101653148 implements Reversible
|
||||
await context.runQuery(
|
||||
`ALTER TABLE ${executionMetadataTableTemp} RENAME TO ${executionMetadataTable};`,
|
||||
);
|
||||
|
||||
if (context.dbType === 'postgresdb') {
|
||||
// Update sequence so that inserts continue with the next highest id.
|
||||
const tableName = escape.tableName('execution_metadata');
|
||||
const sequenceName = escape.tableName('execution_metadata_temp_id_seq1');
|
||||
|
||||
await context.runQuery(
|
||||
`SELECT setval('${sequenceName}', (SELECT MAX(id) FROM ${tableName}));`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { IrreversibleMigration, MigrationContext } from '@db/types';
|
||||
|
||||
export class FixExecutionMetadataSequence1721377157740 implements IrreversibleMigration {
|
||||
async up({ queryRunner, escape }: MigrationContext) {
|
||||
const tableName = escape.tableName('execution_metadata');
|
||||
const sequenceName = escape.tableName('execution_metadata_temp_id_seq');
|
||||
|
||||
await queryRunner.query(
|
||||
`SELECT setval('${sequenceName}', (SELECT MAX(id) FROM ${tableName}));`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ import { RemoveNodesAccess1712044305787 } from '../common/1712044305787-RemoveNo
|
||||
import { MakeExecutionStatusNonNullable1714133768521 } from '../common/1714133768521-MakeExecutionStatusNonNullable';
|
||||
import { AddActivatedAtUserSetting1717498465931 } from './1717498465931-AddActivatedAtUserSetting';
|
||||
import { AddConstraintToExecutionMetadata1720101653148 } from '../common/1720101653148-AddConstraintToExecutionMetadata';
|
||||
import { FixExecutionMetadataSequence1721377157740 } from './1721377157740-FixExecutionMetadataSequence';
|
||||
|
||||
export const postgresMigrations: Migration[] = [
|
||||
InitialMigration1587669153312,
|
||||
@@ -119,4 +120,5 @@ export const postgresMigrations: Migration[] = [
|
||||
MakeExecutionStatusNonNullable1714133768521,
|
||||
AddActivatedAtUserSetting1717498465931,
|
||||
AddConstraintToExecutionMetadata1720101653148,
|
||||
FixExecutionMetadataSequence1721377157740,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user