-- Update script (best effort). Run parts manually if your MySQL errors on existing columns.
CREATE TABLE IF NOT EXISTS global_settings (
  id INT PRIMARY KEY,
  transition_effect VARCHAR(32) NOT NULL DEFAULT 'fade',
  duration_sec INT NOT NULL DEFAULT 8,
  transition_sec INT NOT NULL DEFAULT 2,
  border_animated TINYINT(1) NOT NULL DEFAULT 1,
  border_speed INT NOT NULL DEFAULT 5,
  price_blink TINYINT(1) NOT NULL DEFAULT 1,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
INSERT INTO global_settings (id) VALUES (1) ON DUPLICATE KEY UPDATE id=id;

CREATE TABLE IF NOT EXISTS panel_playlist (
  id INT AUTO_INCREMENT PRIMARY KEY,
  panel_id INT NOT NULL,
  item_type ENUM('offer','message') NOT NULL,
  item_id INT NOT NULL,
  position INT NOT NULL DEFAULT 1,
  enabled TINYINT(1) NOT NULL DEFAULT 1,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX idx_panel_pos (panel_id, position),
  INDEX idx_panel_type (panel_id, item_type)
);
