Sample Conversion: PostgreSQL DDL → Drizzle pgTable
Input (PostgreSQL DDL)
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
total_amount NUMERIC(10,2) NOT NULL
); Output (Drizzle pgTable)
import { pgTable, serial, numeric } from "drizzle-orm/pg-core";
export const orders = pgTable("orders", {
id: serial("id").primaryKey(),
totalAmount: numeric("total_amount", { precision: 10, scale: 2 }).notNull(),
}); Frequently Asked Questions
Can I export TypeScript types with Drizzle?
Yes! Drizzle provides type InferSelectModel<typeof table> to infer database types.