| 1 | import { PostgresDatabase } from "@/Planetscale/Postgres/PostgresDatabase.ts"; |
| 2 | import { PostgresRole } from "@/Planetscale/Postgres/PostgresRole.ts"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | |
| 5 | /** |
| 6 | * PlanetScale Postgres used as the container's DATABASE_URL. Like Neon, |
| 7 | * PlanetScale has no local emulator — the pooled URL is a cloud host, so |
| 8 | * the loopback rewrite must leave it alone. |
| 9 | * |
| 10 | * The database name is deterministic so reruns adopt the same cluster |
| 11 | * instead of provisioning a new PS_10 every time (same trick as the |
| 12 | * PlanetScale Hyperdrive fixture). |
| 13 | */ |
| 14 | export const PlanetscaleHostRole = Effect.gen(function* () { |
| 15 | const database = yield* PostgresDatabase("PlanetscaleHostDb", { |
| 16 | name: "alchemy-container-pg-host", |
| 17 | region: { slug: "us-east" }, |
| 18 | clusterSize: "PS_10", |
| 19 | }); |
| 20 | return yield* PostgresRole("PlanetscaleHostRole", { |
| 21 | database, |
| 22 | inheritedRoles: ["postgres"], |
| 23 | }); |
| 24 | }); |