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 migrationsDir, 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,
migrationsDir: schema.out,
});

Drizzle.Schema runs first (because Neon.Branch depends on its out output), regenerates pending migration files, and Neon.Branch then applies them transactionally.

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.