- server.js uses pg (pinned 8.23.1), reads DATABASE_URL, creates the leads table on start, fails fast if Postgres is unreachable - tests run against a real Postgres in a throwaway schema - CI runs the test image against a throwaway Postgres on DinD - k8s: Postgres 18 StatefulSet (Longhorn, 2Gi), init container wait, password secret, network policy app-to-postgres; app no longer needs a volume or Recreate - README: DBeaver via port-forward, CSV export via docs/export-leads.sql Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
23 lines
983 B
SQL
23 lines
983 B
SQL
-- Lead storage for ins-landing-page (PostgreSQL).
|
|
--
|
|
-- Reference only: server.js creates this table itself on first start (CREATE TABLE IF NOT EXISTS),
|
|
-- so nobody needs to run this file on deploy. server.test.js fails if this file and server.js
|
|
-- drift apart.
|
|
--
|
|
-- Changing the schema after go-live: CREATE TABLE IF NOT EXISTS never alters an existing table,
|
|
-- so a new column also needs an ALTER TABLE step against the live database.
|
|
|
|
CREATE TABLE IF NOT EXISTS leads (
|
|
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
name TEXT NOT NULL,
|
|
email TEXT NOT NULL, -- work email; free providers rejected
|
|
phone TEXT NOT NULL, -- phone / WhatsApp, as typed
|
|
company TEXT NOT NULL,
|
|
service TEXT, -- one of the form's options, or NULL
|
|
referrer TEXT, -- site the visitor came from
|
|
utm_source TEXT,
|
|
utm_medium TEXT,
|
|
utm_campaign TEXT
|
|
);
|