diff --git a/VEZA_COMPLETE_MVP_TODOLIST.json b/VEZA_COMPLETE_MVP_TODOLIST.json index ab7d692ab..bb3277d71 100644 --- a/VEZA_COMPLETE_MVP_TODOLIST.json +++ b/VEZA_COMPLETE_MVP_TODOLIST.json @@ -3175,7 +3175,7 @@ "description": "Add table for user notifications", "owner": "backend", "estimated_hours": 3, - "status": "todo", + "status": "completed", "files_involved": [], "implementation_steps": [ { @@ -3196,7 +3196,9 @@ "Unit tests", "Integration tests" ], - "notes": "" + "notes": "", + "completed_at": "2025-12-24T15:12:10.659377", + "implementation_notes": "Created migration 047_notifications.sql for notifications table. Migration includes: id (UUID), user_id (FK to users), type (VARCHAR), title (VARCHAR), content (TEXT), link (VARCHAR), read (BOOLEAN), timestamps (created_at, updated_at, read_at), and appropriate indexes for user_id, read status, created_at, and type. Table structure matches NotificationService usage." }, { "id": "BE-DB-009", diff --git a/veza-backend-api/migrations/047_notifications.sql b/veza-backend-api/migrations/047_notifications.sql new file mode 100644 index 000000000..e761d442a --- /dev/null +++ b/veza-backend-api/migrations/047_notifications.sql @@ -0,0 +1,37 @@ +-- 047_notifications.sql +-- User Notifications (BE-DB-008: Create migration for notifications table) +-- Add table for user notifications + +-- === NOTIFICATIONS === +-- Table for storing user notifications +CREATE TABLE IF NOT EXISTS public.notifications ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + user_id UUID NOT NULL REFERENCES public.users(id) ON DELETE CASCADE, + + -- Notification Content + type VARCHAR(50) NOT NULL, + title VARCHAR(255) NOT NULL, + content TEXT, + link VARCHAR(500), + + -- Status + read BOOLEAN NOT NULL DEFAULT FALSE, + + -- Timestamps + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + read_at TIMESTAMPTZ +); + +-- Indexes +CREATE INDEX IF NOT EXISTS idx_notifications_user_id ON public.notifications(user_id); +CREATE INDEX IF NOT EXISTS idx_notifications_user_id_read ON public.notifications(user_id, read) WHERE read = FALSE; +CREATE INDEX IF NOT EXISTS idx_notifications_created_at_desc ON public.notifications(created_at DESC); +CREATE INDEX IF NOT EXISTS idx_notifications_type ON public.notifications(type); + +-- Comments +COMMENT ON TABLE public.notifications IS 'User notifications for various events'; +COMMENT ON COLUMN public.notifications.type IS 'Type of notification (e.g., follow, like, comment, message)'; +COMMENT ON COLUMN public.notifications.read IS 'Whether the notification has been read'; +COMMENT ON COLUMN public.notifications.read_at IS 'Timestamp when the notification was marked as read'; +