Files
loki/drizzle/0119_build_requests.sql
CatoandClaude Opus 5.5 b495bedb95 feat(change): a new account's build goes to a person instead of a 403 (#1329)
* feat(change): a new account's build goes to a person instead of a 403

On /change, "Make it real" from any account but the operator's met
"Previews are built on Loki's own computers, which this account does not
have" and stopped. The cloud builder only claims the operator's commands,
and that boundary stays; what changes is that the request no longer dies.

- It is filed (build_requests, migration 0119) with the before/after the
  visitor just saw, once per brief however often it is sent, and the
  operator is told by push, Telegram and an alert.
- /approvals shows it (operator only): Approve builds it as the operator's
  client work; Decline sends their note. Exactly one decision wins, and an
  approval whose build cannot start goes back to waiting with the reason.
- The visitor follows it on /change/requests/<id> and gets an email.
- The preview opens with a code of its own (entities.metadata.previewCode,
  read by getProjectPreviewCode wherever a preview is opened or signed for),
  never the operator's code, which opens every preview they have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyfPCAeTFi2sjpVY44Y1JJ

* docs(telegram): register the build-request notification

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyfPCAeTFi2sjpVY44Y1JJ

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-19 17:21:51 +02:00

20 lines
1.1 KiB
SQL

CREATE TABLE "build_requests" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"user_id" uuid NOT NULL,
"request_id" text NOT NULL,
"website" text NOT NULL,
"brief" jsonb NOT NULL,
"look" jsonb,
"status" text DEFAULT 'waiting' NOT NULL,
"project_id" uuid,
"preview_url" text,
"access_code" text,
"note" text,
"decided_at" timestamp with time zone,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "build_requests" ADD CONSTRAINT "build_requests_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "build_requests" ADD CONSTRAINT "build_requests_project_id_entities_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."entities"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "build_request_user_request" ON "build_requests" USING btree ("user_id","request_id");--> statement-breakpoint
CREATE INDEX "build_request_status" ON "build_requests" USING btree ("status","created_at");