-- Add max_booking_weeks column to practitioners table
ALTER TABLE practitioners
ADD COLUMN max_booking_weeks INT DEFAULT 4 COMMENT 'Nombre de semaines max pour réserver à l\'avance';

-- Create blocked_periods table for vacation/unavailability periods
CREATE TABLE IF NOT EXISTS blocked_periods (
    id INT AUTO_INCREMENT PRIMARY KEY,
    practitioner_id INT NOT NULL,
    start_date DATE NOT NULL,
    end_date DATE NOT NULL,
    reason VARCHAR(255) DEFAULT NULL COMMENT 'Reason for blocking (vacation, formation, etc)',
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (practitioner_id) REFERENCES practitioners(id) ON DELETE CASCADE,
    INDEX idx_practitioner_dates (practitioner_id, start_date, end_date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Sample data: Add a default max_booking_weeks for existing practitioners
UPDATE practitioners SET max_booking_weeks = 4 WHERE max_booking_weeks IS NULL;
