Adds website_submissions table + shared-secret POST endpoint so the marketing site can dual-write inquiries alongside its NocoDB write. Race-safe via INSERT ... ON CONFLICT, idempotent on submission_id, refuses every request when WEBSITE_INTAKE_SECRET is unset. Also repairs pre-existing 0020/0021/0022 prevId collision (renumbered + journal re-sorted) so db:generate works again. 11 unit tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
16 lines
868 B
SQL
16 lines
868 B
SQL
CREATE TABLE "website_submissions" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"port_id" text NOT NULL,
|
|
"submission_id" text NOT NULL,
|
|
"kind" text NOT NULL,
|
|
"payload" jsonb NOT NULL,
|
|
"legacy_nocodb_id" text,
|
|
"source_ip" text,
|
|
"user_agent" text,
|
|
"received_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "website_submissions" ADD CONSTRAINT "website_submissions_port_id_ports_id_fk" FOREIGN KEY ("port_id") REFERENCES "public"."ports"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "idx_ws_submission_id" ON "website_submissions" USING btree ("submission_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_ws_port_received" ON "website_submissions" USING btree ("port_id","received_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_ws_kind" ON "website_submissions" USING btree ("kind"); |