espace-paie-odentas/supabase/migrations/add_notification_timestamps_to_contracts.sql
odentas d7bdb1ef08 feat: Add notification tracking system with smart reminders
- Add database columns for last_employer_notification_at and last_employee_notification_at in cddu_contracts
- Update all email sending endpoints to record timestamps (remind-employer, relance-salarie, docuseal-signature, signature-salarie)
- Create smart reminder system with 24h cooldown to prevent spam
- Add progress tracking modal with real-time status (pending/sending/success/error)
- Display actual employer/employee email addresses in reminder modal
- Show notification timestamps in contracts grid with color coding (green/orange/red based on contract start date)
- Change employer email button URL from DocuSeal direct link to /signatures-electroniques
- Create /api/staff/organizations/emails endpoint for bulk email fetching
- Add retroactive migration script for historical email_logs data
- Update Contract TypeScript type and API responses to include new fields
2025-10-22 21:49:35 +02:00

17 lines
1.1 KiB
SQL

-- Migration: Ajout de colonnes pour tracer les dernières notifications de signature
-- Date: 2025-10-22
-- Description: Ajoute last_employer_notification_at et last_employee_notification_at
-- pour suivre les envois individuels et groupés de relances
-- Ajouter les colonnes de timestamp pour les notifications
ALTER TABLE cddu_contracts
ADD COLUMN IF NOT EXISTS last_employer_notification_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS last_employee_notification_at TIMESTAMPTZ;
-- Créer des index pour optimiser les requêtes de tri/filtrage
CREATE INDEX IF NOT EXISTS idx_cddu_contracts_employer_notif ON cddu_contracts(last_employer_notification_at);
CREATE INDEX IF NOT EXISTS idx_cddu_contracts_employee_notif ON cddu_contracts(last_employee_notification_at);
-- Ajouter des commentaires pour la documentation
COMMENT ON COLUMN cddu_contracts.last_employer_notification_at IS 'Timestamp de la dernière notification de signature envoyée à l''employeur (individuelle ou groupée)';
COMMENT ON COLUMN cddu_contracts.last_employee_notification_at IS 'Timestamp de la dernière notification de signature envoyée au salarié';