Skip to content

Drizzle.Schema reference

Source: packages/drizzle/src/Schema.ts

A Drizzle schema managed as an Alchemy resource.

Runs drizzle-kit generate through drizzle-kit’s programmatic API so migration SQL is regenerated as part of alchemy deploy whenever the source schema changes. Ambiguous changes (a rename or a new column/table?) are asked with Alchemy’s prompts during plan. The output directory is intended to be passed straight to a database resource’s migrations prop, giving you a single deploy-driven flow:

const schema = yield* Drizzle.Schema("app-schema", {
schema: "./src/schema.ts",
});
const branch = yield* Neon.Branch("app-branch", {
project,
migrations: schema,
});
const db = yield* Fly.Postgres("Db", {
region: "iad",
migrations: schema,
});

Drizzle.Schema runs first (because the database resource depends on its out output), regenerates pending migration files, and the database resource then applies them.

The resource is delete-safe: removing it from the stack does not wipe the migrations directory, since migration files are typically checked in and shared with other environments.