-- DM attachments + message types (parity with project chat)

ALTER TABLE direct_chat_messages
  MODIFY body TEXT NULL,
  ADD COLUMN message_type ENUM('text', 'image', 'video', 'audio', 'voice_note', 'document', 'system') NOT NULL DEFAULT 'text' AFTER sender_user_id;

CREATE TABLE IF NOT EXISTS direct_chat_attachments (
  id CHAR(36) NOT NULL PRIMARY KEY,
  message_id CHAR(36) NOT NULL,
  storage_key VARCHAR(512) NOT NULL,
  thumbnail_key VARCHAR(512) NULL,
  mime_type VARCHAR(128) NOT NULL,
  size_bytes BIGINT NOT NULL DEFAULT 0,
  original_name VARCHAR(512) NOT NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CONSTRAINT fk_dca_msg FOREIGN KEY (message_id) REFERENCES direct_chat_messages (id) ON DELETE CASCADE
);
