Files
DanceVideos/model/videos_playlists.sql
Gabriel Radureau 65d63ec828 playlist edition
2025-10-13 16:53:15 +02:00

31 lines
1.4 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =========================================================
-- Table principale des playlists
-- =========================================================
CREATE TABLE IF NOT EXISTS playlists (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE NOT NULL,
description TEXT,
type TEXT CHECK (type IN ('manual', 'dynamic')) NOT NULL DEFAULT 'manual',
rules_json TEXT, -- JSON décrivant les règles pour les playlists dynamiques
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- =========================================================
-- Table dassociation vidéos ↔ playlists (manuelles uniquement)
-- =========================================================
CREATE TABLE IF NOT EXISTS video_playlists (
video_file_name TEXT NOT NULL,
playlist_id INTEGER NOT NULL,
position INTEGER DEFAULT 0, -- 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
);
-- =========================================================
-- Index pour accélérer les recherches
-- =========================================================
CREATE INDEX IF NOT EXISTS idx_playlist_type ON playlists(type);
CREATE INDEX IF NOT EXISTS idx_video_playlists_playlist ON video_playlists(playlist_id);