Files
play-life/play-life-backend/migrations/013_refactor_todoist_single_app.sql
Play Life Bot a7128703fe
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 32s
feat: refactor Todoist integration to single app with OAuth
- Single webhook URL for all users

- OAuth authorization flow

- Removed individual webhook tokens

- User identification by todoist_user_id

- Added OAuth endpoints: connect, callback, status, disconnect

- Updated frontend with OAuth flow

- DB migration 013: removed webhook_token, added todoist_user_id, todoist_email, access_token

Version: 2.2.0
2026-01-02 15:34:01 +03:00

46 lines
2.0 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 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)';