25 lines
1.2 KiB
SQL
25 lines
1.2 KiB
SQL
-- CooldownRequest table — tracks user-initiated cooldowns before disabling protection.
|
|
-- Backed by `model CooldownRequest` in schema.prisma.
|
|
--
|
|
-- Drift-Fix: diese Migration wurde nachträglich angelegt (2026-04-28). Auf
|
|
-- staging-DB wurde die Tabelle manuell via psql erstellt. Auf neuen DBs (Prod-
|
|
-- Migration, Dev-Setup) sollte diese Migration laufen.
|
|
--
|
|
-- Wenn ein DB schon die Tabelle hat (Drift): nach dem ersten `prisma migrate deploy`
|
|
-- führe einmalig aus:
|
|
-- pnpm prisma migrate resolve --applied 20260428_add_cooldown_requests
|
|
|
|
CREATE TABLE IF NOT EXISTS "rebreak"."cooldown_requests" (
|
|
"id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
"user_id" UUID NOT NULL,
|
|
"reason" TEXT,
|
|
"cooldown_started_at" TIMESTAMP(3) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"cooldown_ends_at" TIMESTAMP(3) WITH TIME ZONE NOT NULL,
|
|
"resolved_at" TIMESTAMP(3) WITH TIME ZONE,
|
|
"cancelled_at" TIMESTAMP(3) WITH TIME ZONE,
|
|
"token_jti" TEXT NOT NULL UNIQUE
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "cooldown_requests_user_id_cooldown_ends_at_idx"
|
|
ON "rebreak"."cooldown_requests"("user_id", "cooldown_ends_at");
|