Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(database): correct the statement_timeout note on two migrations

Yudhi Armyndharis19d20f93f498
diff --git a/src/database/migrations/1781100000000-AddTemplateNameUnique.ts b/src/database/migrations/1781100000000-AddTemplateNameUnique.ts
index 006884ca7..90ccd2d13 100644
--- a/src/database/migrations/1781100000000-AddTemplateNameUnique.ts
+++ b/src/database/migrations/1781100000000-AddTemplateNameUnique.ts
@@ -18,9 +18,10 @@ export class AddTemplateNameUnique1781100000000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
if (queryRunner.dataSource.options.type === 'postgres') {
- // See AddMessagesWaMessageIdUnique: lift the runtime statement_timeout for this migration
- // transaction so the dedup UPDATE / CREATE UNIQUE INDEX over templates is not aborted. SET LOCAL is
- // transaction-scoped and a no-op on SQLite (which rejects it syntactically — hence the guard).
+ // Boot and CLI migrations run on a pool without the runtime statement_timeout (pg-boot-migrations.ts);
+ // this guards the dedup UPDATE / CREATE UNIQUE INDEX over templates against a role- or database-level
+ // default aborting it mid-flight. SET LOCAL is transaction-scoped (auto-reverts at COMMIT); SQLite
+ // rejects it syntactically, hence the guard.
await queryRunner.query('SET LOCAL statement_timeout = 0');
}
if (!(await queryRunner.hasTable('templates'))) return;
diff --git a/src/database/migrations/__tests__/1781100000000-AddTemplateNameUnique.spec.ts b/src/database/migrations/__tests__/1781100000000-AddTemplateNameUnique.spec.ts
index 5f594bf0d..9e0b74395 100644
--- a/src/database/migrations/__tests__/1781100000000-AddTemplateNameUnique.spec.ts
+++ b/src/database/migrations/__tests__/1781100000000-AddTemplateNameUnique.spec.ts
@@ -76,9 +76,9 @@ describe('AddTemplateNameUnique migration', () => {
await runner.release();
});
- it('lifts the runtime statement_timeout for the migration transaction on Postgres', async () => {
- // The runtime data pool's statement_timeout is inherited by the boot-migration connection; this
- // dedup UPDATE / CREATE UNIQUE INDEX over templates must not be aborted mid-flight.
+ it('clears statement_timeout for the migration transaction on Postgres', async () => {
+ // The migration pool carries no runtime statement_timeout, but a role- or database-level default
+ // could still abort this dedup UPDATE / CREATE UNIQUE INDEX over templates mid-flight.
const queries: string[] = [];
const pgRunner = {
dataSource: { options: { type: 'postgres' } },
diff --git a/src/database/migrations/__tests__/1781300000000-AddMessagesWaMessageIdUnique.spec.ts b/src/database/migrations/__tests__/1781300000000-AddMessagesWaMessageIdUnique.spec.ts
index c13ad8649..5eeda89d2 100644
--- a/src/database/migrations/__tests__/1781300000000-AddMessagesWaMessageIdUnique.spec.ts
+++ b/src/database/migrations/__tests__/1781300000000-AddMessagesWaMessageIdUnique.spec.ts
@@ -65,9 +65,9 @@ describe('AddMessagesWaMessageIdUnique migration', () => {
await runner.release();
});
- it('lifts the runtime statement_timeout for the migration transaction on Postgres', async () => {
- // The runtime data pool carries a statement_timeout that is inherited by the boot-migration
- // connection; this DELETE / CREATE UNIQUE INDEX over the hot messages table must not be aborted.
+ it('clears statement_timeout for the migration transaction on Postgres', async () => {
+ // The migration pool carries no runtime statement_timeout, but a role- or database-level default
+ // could still abort this DELETE / CREATE UNIQUE INDEX over the hot messages table mid-flight.
const queries: string[] = [];
const pgRunner = {
dataSource: { options: { type: 'postgres' } },