feat: add PostgreSQL backend

Mirrors the node:sqlite sub-backend structure with full migration support.
Uses native pg types (UUID, JSONB, TIMESTAMPTZ) and $1/$2 parameterisation
via internal ? placeholders converted at execution time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 02:00:10 +00:00
co-authored by Claude
parent dd8d31633f
commit 4521274a27
22 changed files with 1273 additions and 1 deletions
+18
View File
@@ -0,0 +1,18 @@
export const pgProtocols = ["postgres:", "postgresql:"];
export function isPgUrl(url: string): boolean {
try {
const urlObj = new URL(url);
return pgProtocols.includes(urlObj.protocol);
} catch {
return false;
}
}
export function parsePgUrl(url: string): { connectionString: string; readonly: boolean } {
if (!isPgUrl(url)) throw new Error("Not a postgres: URL");
const urlObj = new URL(url);
const readonly = (urlObj.searchParams.get("readonly") ?? "0") !== "0";
urlObj.searchParams.delete("readonly");
return { connectionString: urlObj.toString(), readonly };
}