-- TV Dashboard Slides Management
-- Run this script to create the tables for TV slide management

-- Table to store slide presentations/folders
CREATE TABLE IF NOT EXISTS tv_presentations (
    presentationid INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    folder_path VARCHAR(500) NOT NULL COMMENT 'Full path or subfolder name under base path',
    interval_seconds INT DEFAULT 10 COMMENT 'Seconds between slides',
    isactive TINYINT(1) DEFAULT 0 COMMENT 'Only one should be active at a time',
    created_date DATETIME DEFAULT CURRENT_TIMESTAMP,
    lastupdated DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    notes VARCHAR(500)
);

-- Table to store individual slides (optional - for when you want to manage slides in DB)
CREATE TABLE IF NOT EXISTS tv_slides (
    slideid INT AUTO_INCREMENT PRIMARY KEY,
    presentationid INT NOT NULL,
    filename VARCHAR(255) NOT NULL,
    display_order INT DEFAULT 0,
    isactive TINYINT(1) DEFAULT 1,
    created_date DATETIME DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (presentationid) REFERENCES tv_presentations(presentationid) ON DELETE CASCADE
);

-- Insert default presentation
INSERT INTO tv_presentations (name, folder_path, interval_seconds, isactive, notes)
VALUES ('Default', 'S:\\ProcessData\\CommDisplay\\ShopSS', 10, 1, 'Default presentation folder');

-- Example: Add a holiday presentation (inactive by default)
-- INSERT INTO tv_presentations (name, folder_path, interval_seconds, isactive, notes)
-- VALUES ('Christmas 2025', 'Christmas2025', 10, 0, 'Holiday slides - subfolder of base path');
