mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 14:16:12 +00:00
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.
25 lines
1.0 KiB
SQL
25 lines
1.0 KiB
SQL
-- 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.
|
|
--
|
|
-- 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,
|
|
"prompt_msg_id" INTEGER NOT NULL,
|
|
"kind" TEXT NOT NULL,
|
|
"ref_id" TEXT NOT NULL,
|
|
"expires_at" TIMESTAMP(3) NOT NULL,
|
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "telegram_prompt_contexts_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
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 IF NOT EXISTS "telegram_prompt_contexts_expires_at_idx" ON "telegram_prompt_contexts"("expires_at");
|