dorfteich/apps/api/prisma/migrations/20260711230000_watches/migration.sql
Claude Fable 5 f4f27cbe78
All checks were successful
CI / Lint, typecheck, test (push) Successful in 3m23s
CI / Build container images (push) Has been skipped
CD / Build and push images (push) Successful in 3m47s
CD / Deploy to Test (push) Successful in 11s
CD / Smoke tests against Test (push) Successful in 1m14s
CD / Promote to Int (push) Successful in 10s
CI / Auth e2e pack (push) Successful in 5m28s
CI / Import/export fidelity gate (push) Successful in 46s
Add watches: follow pages and ponds with auto-watch preferences (#93)
New watches table (polymorphic target, unique per user+target; page purge
removes its rows via the trash service, and the list endpoint drops
targets the user can no longer read). Endpoints: idempotent PUT/DELETE
/watches/{page|pond}/:id gated by read access (404 hides the target),
GET state for the header toggles, and GET /users/me/watches resolving
names and links. Auto-watch hooks: creating a page and commenting
subscribe the actor, each behind a new user preference
(autoWatchOwnPages / autoWatchOnComment, default on) editable via the
profile PATCH and surfaced as checkboxes in the settings. UI: watch
toggle on the page header and the pond settings header, watch list with
unwatch in the account settings; new watches i18n namespace (de+en).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EwZ4jR4KFAPvpjWevfUGX1
2026-07-11 22:59:11 +02:00

24 lines
917 B
SQL

-- Watches + auto-watch preferences (issue #93).
ALTER TABLE "users" ADD COLUMN "auto_watch_own_pages" BOOLEAN NOT NULL DEFAULT true;
ALTER TABLE "users" ADD COLUMN "auto_watch_on_comment" BOOLEAN NOT NULL DEFAULT true;
CREATE TYPE "WatchTargetType" AS ENUM ('PAGE', 'POND');
CREATE TABLE "watches" (
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"target_type" "WatchTargetType" NOT NULL,
"target_id" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "watches_pkey" PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX "watches_user_id_target_type_target_id_key"
ON "watches"("user_id", "target_type", "target_id");
CREATE INDEX "watches_target_type_target_id_idx" ON "watches"("target_type", "target_id");
ALTER TABLE "watches" ADD CONSTRAINT "watches_user_id_fkey"
FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;