Prisma Postgres
Prerequisites
Section titled “Prerequisites”- A Prisma Postgres workspace
- A service token with workspace access
PRISMA_SERVICE_TOKEN
set in your environment
Install Dependencies
Section titled “Install Dependencies”bun i alchemy
Configure the Service Token
Section titled “Configure the Service Token”Create a workspace service token in the Prisma dashboard and export it before running Alchemy commands:
export PRISMA_SERVICE_TOKEN="sk_..."
Create a Project and Database
Section titled “Create a Project and Database”import alchemy from "alchemy";import { Connection, Database, Project } from "alchemy/prisma-postgres";
const app = await alchemy("prisma-postgres-example");
const project = await Project("project");
const database = await Database("database", { project, region: "us-east-1",});
const connection = await Connection("connection", { database });
console.log("Database URL", connection.connectionString.unencrypted);
await app.finalize();
Cleanup
Section titled “Cleanup”To remove all resources created by the guide, run:
alchemy destroy
Next Steps
Section titled “Next Steps”- Explore setting up Prisma Postgres with Cloudflare Hyperdrive
- Set up a cloudflare worker to consume the Prisma Postgres database
- Explore using multiple Prisma Postgres workspaces in an alchemy project
- Join our Discord for support and updates.