This skill should be used when the user asks to "create a migration", "modify a database schema", "add a table", "update Drizzle/Prisma/EF Core schema", or works on PostgreSQL data models.
Apply when modifying database schemas with EF Core (.NET), Prisma (Next.js), or Drizzle (Astro). Default DB: PostgreSQL 18.
snake_case for tables, columns, indexes, constraintsorders, order_items)id (UUID or serial, project decides){referenced_table_singular}_id (e.g. order_id)ix_{table}_{columns} (e.g. ix_orders_customer_id)uq_{table}_{columns}created_at, updated_at (UTC, timestamptz)# Create migration
dotnet ef migrations add Add{Entity}Table --project src/{Project}.Infrastructure
# Apply to local DB
dotnet ef database update --project src/{Project}.Infrastructure
# Generate SQL script (review or production)
dotnet ef migrations script --idempotent --project src/{Project}.Infrastructure
Add{Entity}Table, Add{Column}To{Table}, Remove{Column}From{Table}IEntityTypeConfiguration<T> for entity config — one file per entityUseSnakeCaseNamingConvention() via EFCore.NamingConventionsHasData() in configuration for static reference data onlydotnet ef migrations list to verify migration ordernpx prisma migrate dev --name add_{entity}_table # Dev (creates + applies)
npx prisma migrate deploy # Production (apply pending)
npx prisma migrate reset # Reset (destructive — dev only)
prisma/schema.prisma — single source of truthnpx prisma generate after schema changes@map and @@map for snake_case table/column namesnpx drizzle-kit generate # Generate migration from schema changes
npx drizzle-kit migrate # Apply migrations
npx drizzle-kit push # Push schema directly (dev only, no migration file)
src/lib/db/schema.tspgTable() with explicit column definitionsrelations() helper