mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-31 16:57:08 +02:00
919 B
919 B
AGENTS.md
Extra information specific to the @n8n/db package.
Migration DSL
UUID Primary Keys
Do not use autoGenerate or autoGenerate2 on UUID columns. Both cause
TypeORM to emit DEFAULT uuid_generate_v4() in PostgreSQL, which requires the
uuid-ossp extension in the public schema. This fails on managed Postgres
services like Supabase where the extension lives in a different schema.
Instead, generate UUIDs at the application level:
Migration:
column('id').uuid.primary.notNull,
Entity:
import { randomUUID } from 'node:crypto';
import { BeforeInsert, PrimaryColumn } from '@n8n/typeorm';
@PrimaryColumn('uuid')
id: string;
@BeforeInsert()
generateId() {
if (!this.id) {
this.id = randomUUID();
}
}
autoGenerate / autoGenerate2 are fine for integer columns (they use
serial / GENERATED BY DEFAULT AS IDENTITY respectively).