Quick start
Lets build a quick start app with PostgreSQL + postgresjs and run our first migration.
The first thing we need to do is to install drizzle-orm and drizzle-kit:
 npm 
 yarn 
 pnpm 
 bun 
 npm i drizzle-orm postgres
npm i -D drizzle-kityarn add drizzle-orm postgres
yarn add -D drizzle-kitpnpm add drizzle-orm postgres
pnpm add -D drizzle-kitbun add drizzle-orm postgres
bun add -D drizzle-kitLets declare our schema.ts:
📦 <project root>
 ├ ...
 ├ 📂 src
 │ └ 📜 schema.ts
 └ 📜 package.jsonimport { serial, text, timestamp, pgTable } from "drizzle-orm/pg-core";
export const user = pgTable("user", {
  id: serial("id"),
  name: text("name"),
  email: text("email"),
  password: text("password"),
  role: text("role").$type<"admin" | "customer">(),
  createdAt: timestamp("created_at"),
  updatedAt: timestamp("updated_at"),
});Now lets add drizzle configuration file:
📦 <project root>
 ├ ...
 ├ 📂 src
 ├ 📜 drizzle.config.ts
 └ 📜 package.jsonimport { defineConfig } from "drizzle-kit";
export default defineConfig({
  dialect: "postgresql",
  schema: "./src/schema.ts",
  out: "./drizzle",
});Add generate and migrate commands to package.json and run our first migrations generation:
{
  "name": "first time?",
  "version": "0.0.1",
  "scripts": {
    "generate": "drizzle-kit generate",
    "migrate": "drizzle-kit migrate"
  }, 
}$ npm run generate
...
[✓] Your SQL migration file ➜ drizzle/0000_pale_mister_fear.sql 🚀Done! We now have our first SQL migration file 🥳
📦 <project root>
 ├ 📂 drizzle
 │ ├ 📂 _meta
 │ └ 📜 0000_pale_mister_fear.sql
 ├ 📂 src
 ├ 📜 drizzle.config.ts
 └ 📜 package.jsonNow lets run our first migration to the database:
$ npm run migrateThat’s it, folks!
My personal congratulations 🎉