(value: string)
| 10 | * migrations use the direct endpoint because code migrations hold session locks. |
| 11 | */ |
| 12 | export 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 |
no outgoing calls
no test coverage detected