4.0.0: Исправлена обработка старых дампов
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m19s

This commit is contained in:
poignatov
2026-01-25 16:41:50 +03:00
parent b8ef59bfd1
commit 90643c504a
42 changed files with 2052 additions and 1157 deletions

View File

@@ -0,0 +1,45 @@
-- Migration: Refactor todoist_integrations for single Todoist app
-- Webhook теперь единый для всего приложения, токены в URL больше не нужны
-- Все пользователи используют одно Todoist приложение
-- ============================================
-- 1. Добавляем новые поля
-- ============================================
ALTER TABLE todoist_integrations
ADD COLUMN IF NOT EXISTS todoist_user_id BIGINT;
ALTER TABLE todoist_integrations
ADD COLUMN IF NOT EXISTS todoist_email VARCHAR(255);
ALTER TABLE todoist_integrations
ADD COLUMN IF NOT EXISTS access_token TEXT;
-- ============================================
-- 2. Удаляем webhook_token (больше не нужен!)
-- ============================================
ALTER TABLE todoist_integrations
DROP COLUMN IF EXISTS webhook_token;
-- ============================================
-- 3. Удаляем старый индекс на webhook_token
-- ============================================
DROP INDEX IF EXISTS idx_todoist_integrations_webhook_token;
-- ============================================
-- 4. Создаем новые индексы
-- ============================================
CREATE UNIQUE INDEX IF NOT EXISTS idx_todoist_integrations_todoist_user_id
ON todoist_integrations(todoist_user_id)
WHERE todoist_user_id IS NOT NULL;
CREATE UNIQUE INDEX IF NOT EXISTS idx_todoist_integrations_todoist_email
ON todoist_integrations(todoist_email)
WHERE todoist_email IS NOT NULL;
-- ============================================
-- 5. Комментарии
-- ============================================
COMMENT ON COLUMN todoist_integrations.todoist_user_id IS 'Todoist user ID (from OAuth) - used to identify user in webhooks';
COMMENT ON COLUMN todoist_integrations.todoist_email IS 'Todoist user email (from OAuth)';
COMMENT ON COLUMN todoist_integrations.access_token IS 'Todoist OAuth access token (permanent)';