-- ============================================================================
-- MIGRATION: Create Track Obstacles Table
-- Date: 2025-12-12
-- Description: Create table to store 4x4 track obstacles with positioning and details
-- ============================================================================

CREATE TABLE IF NOT EXISTS track_obstacles (
    obstacle_id INT PRIMARY KEY AUTO_INCREMENT,
    name VARCHAR(100) NOT NULL COMMENT 'Obstacle name (e.g., "Rock Crawl", "Water Crossing")',
    x_position INT NOT NULL COMMENT 'X pixel position on the track map',
    y_position INT NOT NULL COMMENT 'Y pixel position on the track map',
    difficulty VARCHAR(20) NOT NULL COMMENT 'Difficulty level (easy, medium, hard, extreme)',
    description TEXT COMMENT 'Detailed description of the obstacle',
    image_path VARCHAR(255) COMMENT 'Path to obstacle image (e.g., assets/images/obstacles/obstacle1.jpg)',
    marker_color VARCHAR(20) NOT NULL COMMENT 'Marker color: red, green, black, or split (red-green)',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX idx_name (name),
    INDEX idx_difficulty (difficulty)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ============================================================================
-- ROLLBACK INSTRUCTIONS (if needed)
-- ============================================================================
-- DROP TABLE IF EXISTS track_obstacles;
