Skip to content

Commit ce801dd

Browse files
committed
Suppress duplicate Postgres migration notices
1 parent 0811b76 commit ce801dd

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/generators/node/database.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ describe('generateDatabase — src/database/index.ts', () => {
7272
const content = await read('src/database/index.ts');
7373
expect(content).toContain('postgres');
7474
expect(content).toContain('drizzle-orm/postgres-js');
75+
expect(content).toContain('onnotice');
76+
expect(content).toContain("'42P06'");
77+
expect(content).toContain("'42P07'");
7578
expect(content).toContain('export');
7679
});
7780

src/generators/node/database.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ function dbClientContent(database: GeneratorOptions['database']): string {
110110
import postgres from 'postgres';
111111
import * as schema from './schema.js';
112112
113-
const client = postgres(process.env.DATABASE_URL!);
113+
const client = postgres(process.env.DATABASE_URL!, {
114+
onnotice: (notice) => {
115+
if (notice.code === '42P06' || notice.code === '42P07') return;
116+
console.warn(notice);
117+
},
118+
});
114119
export const db = drizzle(client, { schema });
115120
`;
116121
}

0 commit comments

Comments
 (0)