drizzle-kit
, for managing migrations and few other things.
This guide will show you how to use Drizzle Kit CLI to manage your schema migrations. We are going to assume that you already have a project set up with your
favorite Typescript framework.
Start from example project
drizzle-kit
, drizzle-orm
, dotenv
, and pg-node
- all of which are needed for this guide. pg-node
can be replaced with another postgres client like postgres.js
.To run this example, you’ll need a .env file with a DATABASE_URL environment variable set to a postgres database.
You can copy the connection string from your Nile database home page.Configure Drizzle
drizzle.config.ts
file, which you can find in the root of the example project.Here’s an example drizzle.config.ts
file. You’ll need to set:schema
field to the path to your schema fileout
field to the path where you want to store your migrationsdialect
field to postgresql
for Nile databasesdbCredentials
field with your database credentialsDefine Your Schema
src/db/schema.ts
. Note that we include the built-in tenants
table that Nile automatically provisions:Generate and Run Migrations
Seed and Query Data
src/index.ts
):Make Schema Changes