-- Migration 084: Add pinning and custom naming to chat conversations
-- Date: 2026-03-16

ALTER TABLE ai_chat_conversations ADD COLUMN IF NOT EXISTS is_pinned BOOLEAN DEFAULT FALSE;
ALTER TABLE ai_chat_conversations ADD COLUMN IF NOT EXISTS pinned_at TIMESTAMP;
ALTER TABLE ai_chat_conversations ADD COLUMN IF NOT EXISTS custom_name VARCHAR(255);

-- Index for efficient pinned conversations query
CREATE INDEX IF NOT EXISTS idx_chat_conversations_pinned ON ai_chat_conversations(user_id, is_pinned, updated_at DESC);

-- Grants
GRANT ALL ON TABLE ai_chat_conversations TO nordabiz_app;
