Part 4: Stages
A stage is a separate copy of your Stack. With Convex, each one gets its own data.
Deploy a second stage
Section titled “Deploy a second stage”pnpm alchemy deploy --stage pr-42bun alchemy deploy --stage pr-42npx alchemy deploy --stage pr-42yarn alchemy deploy --stage pr-42type: "preview" makes one deployment per stage, named after the stage. pr-42 starts with no data.
Use prod for production
Section titled “Use prod for production”Previews expire, and Convex removes them. Use type: "prod" for real data:
import * as Convex from "@alchemy.run/convex";import * as RemovalPolicy from "alchemy/RemovalPolicy";import { Stack } from "alchemy/Stack";import * as Effect from "effect/Effect";
export const Project = Convex.Project("Project").pipe(RemovalPolicy.destroy());
export const Backend = Effect.gen(function* () { const { stage } = yield* Stack; const project = yield* Project; return yield* Convex.Deployment("Backend", { project, type: "preview" }); return yield* Convex.Deployment("Backend", { project, type: stage === "prod" ? "prod" : "preview", });});A prod deployment has deletionProtection on, so alchemy destroy fails rather than deleting its data.
Remove a stage
Section titled “Remove a stage”pnpm alchemy destroy --stage pr-42bun alchemy destroy --stage pr-42npx alchemy destroy --stage pr-42yarn alchemy destroy --stage pr-42