Добавлена связь задач с желаниями
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 58s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 58s
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
-- Migration: Add wishlist_id to tasks table for linking tasks to wishlist items
|
||||
-- This allows creating tasks directly from wishlist items and tracking the relationship
|
||||
|
||||
-- Добавляем поле wishlist_id в таблицу tasks
|
||||
ALTER TABLE tasks
|
||||
ADD COLUMN IF NOT EXISTS wishlist_id INTEGER REFERENCES wishlist_items(id) ON DELETE SET NULL;
|
||||
|
||||
-- Создаём индекс для быстрого поиска задач по wishlist_id
|
||||
CREATE INDEX IF NOT EXISTS idx_tasks_wishlist_id ON tasks(wishlist_id);
|
||||
|
||||
-- Уникальный индекс: только одна незавершённая задача на желание
|
||||
-- Это предотвращает создание нескольких задач для одного желания
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_tasks_wishlist_id_unique
|
||||
ON tasks(wishlist_id) WHERE wishlist_id IS NOT NULL AND deleted = FALSE;
|
||||
|
||||
-- Добавляем комментарий для документации
|
||||
COMMENT ON COLUMN tasks.wishlist_id IS 'Link to wishlist item that this task fulfills. NULL if task is not linked to any wishlist item.';
|
||||
|
||||
Reference in New Issue
Block a user