From 5c0583133dc2715dfe69c49188a4b99ae2a48538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 21 Jun 2026 21:06:17 +0200 Subject: [PATCH] chore(db): make the 0187 telegram-prompt-context migration rerun-safe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Guard the CREATE TABLE + both CREATE INDEX statements with IF NOT EXISTS so a re-run on a database that already has the table is a no-op, matching the guard convention every other recent migration ships with. Semantics are unchanged — same table, same columns, same indexes. --- .../0187_v1190_telegram_prompt_context/migration.sql | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/prisma/migrations/0187_v1190_telegram_prompt_context/migration.sql b/prisma/migrations/0187_v1190_telegram_prompt_context/migration.sql index aab9f45f5..3f8c027f2 100644 --- a/prisma/migrations/0187_v1190_telegram_prompt_context/migration.sql +++ b/prisma/migrations/0187_v1190_telegram_prompt_context/migration.sql @@ -1,6 +1,10 @@ -- v1.19.0 — force-reply correlation for the interactive mood reminder. -- Maps a bot prompt message to the entry a free-text reply attaches to. -CREATE TABLE "telegram_prompt_contexts" ( +-- +-- Idempotent guards (`IF NOT EXISTS`) so a rerun is safe on prod. The +-- semantics are unchanged from the original cut (same table, same columns, +-- same indexes) — v1.19.2 added only the guards. +CREATE TABLE IF NOT EXISTS "telegram_prompt_contexts" ( "id" TEXT NOT NULL, "user_id" TEXT NOT NULL, "chat_id" TEXT NOT NULL, @@ -14,7 +18,7 @@ CREATE TABLE "telegram_prompt_contexts" ( ); -- CreateIndex -CREATE UNIQUE INDEX "telegram_prompt_contexts_chat_id_prompt_msg_id_key" ON "telegram_prompt_contexts"("chat_id", "prompt_msg_id"); +CREATE UNIQUE INDEX IF NOT EXISTS "telegram_prompt_contexts_chat_id_prompt_msg_id_key" ON "telegram_prompt_contexts"("chat_id", "prompt_msg_id"); -- CreateIndex -CREATE INDEX "telegram_prompt_contexts_expires_at_idx" ON "telegram_prompt_contexts"("expires_at"); +CREATE INDEX IF NOT EXISTS "telegram_prompt_contexts_expires_at_idx" ON "telegram_prompt_contexts"("expires_at");