godcrm/backend/database/migrations/010-chat-unread.sql
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

14 lines
538 B
SQL

-- Migration: Add last_read_at column to conversation_participants
-- For tracking unread messages
-- PostgreSQL version
ALTER TABLE conversation_participants
ADD COLUMN IF NOT EXISTS last_read_at TIMESTAMP;
-- Create index for faster unread queries
CREATE INDEX IF NOT EXISTS idx_conv_part_last_read
ON conversation_participants(conversation_id, user_id, last_read_at);
-- Create index on messages for unread counting
CREATE INDEX IF NOT EXISTS idx_messages_conv_sender_created
ON messages(conversation_id, sender_id, created_at);