Skip to content

Schema

Source: src/Drizzle/Schema.ts

A Drizzle schema managed as an Alchemy resource.

Wraps drizzle-kit’s programmatic API (generateDrizzleJson / generateMigration) so migration SQL is regenerated as part of alchemy deploy whenever the source schema changes. 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.