Files
pagodera/lib/db/migrations/010_notifications.sql
T
Evandro Fonseca Junior 55eebde0ba feat: add user authentication UI to header component
Add login and register dialogs, user dropdown menu with profile link and logout option, and integrate with session management hook. Prevent hydration mismatches by conditionally rendering auth elements after mount. Update package-lock.json with new @esbuild dependencies for build tooling.
2025-11-04 02:33:29 -03:00

24 lines
1.1 KiB
SQL

-- Migration 010: Tabela de notificações
-- Criado em: 2025-01-27
-- Tabela de notificações
CREATE TABLE IF NOT EXISTS notifications (
notification_id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
notification_type VARCHAR(30) CHECK (notification_type IN ('bid', 'sale', 'purchase', 'escrow', 'dispute', 'system')),
title VARCHAR(255) NOT NULL,
message TEXT NOT NULL,
related_id INTEGER, -- ID da transação/listing relacionado
is_read BOOLEAN DEFAULT FALSE,
send_whatsapp BOOLEAN DEFAULT FALSE,
whatsapp_sent BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Índices para performance
CREATE INDEX IF NOT EXISTS idx_notifications_user ON notifications(user_id, is_read);
CREATE INDEX IF NOT EXISTS idx_notifications_type ON notifications(notification_type);
CREATE INDEX IF NOT EXISTS idx_notifications_created_at ON notifications(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_notifications_unread ON notifications(user_id, is_read) WHERE is_read = FALSE;