Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 1.11 KB

README.md

File metadata and controls

50 lines (37 loc) · 1.11 KB

Example project for Drizzle ORM D1 SQLite package Subscribe to our updates on Twitter!

Initial project setup

To setup project for your Cloudflare D1 - please refer to official docs

## your wrangler.toml will look something like this

name = "YOU PROJECT NAME"
main = "src/index.ts"
compatibility_date = "2022-11-07"
node_compat = true

[[ d1_databases ]]
binding = "DB"
database_name = "YOU DB NAME"
database_id = "YOUR DB ID"

To init local database and run server locally

wrangler d1 execute <DATABASE_NAME> --local --file=./drizzle/0000_short_lockheed.sql
wrangler dev --local --persist

Install Drizzle ORM

npm install drizzle-orm

To automatically generate migration .sql files, when src/schema.ts chages

npm install drizzle-kit

## package.json
{
  ...
  scripts: {
    "generate": "drizzle-kit generate:sqlite --schema=src/schema.ts",
    "up": "drizzle-kit up:sqlite --schema=src/schema.ts"
  }
}

npm run generate