MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / directDatabaseUrl

Function directDatabaseUrl

apps/cloud/scripts/database-connection.ts:12–26  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

10 * migrations use the direct endpoint because code migrations hold session locks.
11 */
12export const directDatabaseUrl = (value: string): string => {
13 let url: URL;
14 try {
15 url = new URL(value);
16 } catch {
17 throw new Error("DATABASE_URL must be a valid PostgreSQL URL");
18 }
19 if (url.protocol !== "postgres:" && url.protocol !== "postgresql:") {
20 throw new Error("DATABASE_URL must use the postgres or postgresql protocol");
21 }
22 if (url.hostname.endsWith(".psdb.cloud") && url.port !== "" && url.port !== "5432") {
23 throw new Error("PlanetScale deploy scripts require the direct endpoint on port 5432");
24 }
25 return value;
26};
27
28/**
29 * Open the CLI's single connection before starting work. Retry only PostgreSQL

Calls

no outgoing calls

Tested by

no test coverage detected