Generate migrations with:
pnpm drizzle-kit generate:pg
Run with:
pnpm tsx ./migrate.ts
Generate migrations with:
pnpm drizzle-kit generate:pg
Run with:
pnpm tsx ./migrate.ts
import "dotenv/config"; | |
import type { Config } from "drizzle-kit"; | |
export default { | |
schema: "./path/to/schema.ts", | |
out: "./drizzle", | |
driver: "pg", | |
dbCredentials: { | |
connectionString: process.env.POSTGRES_URL!, | |
}, | |
} satisfies Config; |
import { loadEnvConfig } from "@next/env"; | |
import { drizzle } from "drizzle-orm/vercel-postgres"; | |
import { migrate } from "drizzle-orm/vercel-postgres/migrator"; | |
import { sql } from "@vercel/postgres"; | |
const dev = process.env.NODE_ENV !== "production"; | |
loadEnvConfig("./", dev); | |
export const db = drizzle(sql); | |
migrate(db, { migrationsFolder: "./drizzle" }); |