diff --git a/src/GmRelay.Bot/Migrations/V031__add_wizard_drafts.sql b/src/GmRelay.Bot/Migrations/V031__add_wizard_drafts.sql new file mode 100644 index 0000000..630822a --- /dev/null +++ b/src/GmRelay.Bot/Migrations/V031__add_wizard_drafts.sql @@ -0,0 +1,21 @@ +-- V031: Per-(chat, thread, owner) wizard drafts for the game-creation wizard (issue #111). +-- Stores in-progress wizard state in JSONB with a 24h TTL managed by WizardDraftCleanupService. + +CREATE TABLE wizard_drafts ( + id UUID PRIMARY KEY, + chat_id BIGINT NOT NULL, + message_thread_id INT, + owner_telegram_id BIGINT NOT NULL, + step TEXT NOT NULL, + payload JSONB NOT NULL, + draft_message_id BIGINT, + created_at TIMESTAMPTZ NOT NULL, + updated_at TIMESTAMPTZ NOT NULL, + expires_at TIMESTAMPTZ NOT NULL +); + +CREATE INDEX idx_wizard_drafts_owner + ON wizard_drafts(chat_id, message_thread_id, owner_telegram_id); + +CREATE INDEX idx_wizard_drafts_expires + ON wizard_drafts(expires_at);