-- Migration: Create servers table
-- Description: episode_id, type, server_name (actual name e.g. Vidcloud, AnimeWorld), embed (empty)

CREATE TABLE IF NOT EXISTS servers (
  id INT AUTO_INCREMENT PRIMARY KEY,
  episode_id VARCHAR(300) NOT NULL COMMENT 'Episode id from ep= parameter',
  type VARCHAR(50) NOT NULL COMMENT 'sub, dub, hindi, ml, hindi/bn/ml/tm, etc.',
  server_name VARCHAR(100) NOT NULL COMMENT 'Actual server name e.g. Vidcloud, AnimeWorld, Mega',
  embed VARCHAR(500) NULL DEFAULT NULL COMMENT 'Empty; reserved for embed URL if needed',
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

  UNIQUE KEY unique_servers_entry (episode_id, type, server_name, embed),
  INDEX idx_episode_id (episode_id),
  INDEX idx_type (type),
  INDEX idx_server_name (server_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE servers COMMENT = 'Stores episode id, type, server name (actual name); embed empty';
