-- Table des playlists
CREATE TABLE IF NOT EXISTS playlists (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name VARCHAR(100) UNIQUE NOT NULL,
  description TEXT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Table d'association entre vidéos et playlists (relation many-to-many)
CREATE TABLE IF NOT EXISTS video_playlists (
  video_file_name VARCHAR(255),
  playlist_id INTEGER,
  position INTEGER, -- pour gérer l’ordre dans la playlist
  PRIMARY KEY (video_file_name, playlist_id),
  FOREIGN KEY (video_file_name) REFERENCES videos(file_name) ON DELETE CASCADE,
  FOREIGN KEY (playlist_id) REFERENCES playlists(id) ON DELETE CASCADE
);