-- Blocked Dates Table
-- Store dates that are fully booked or blocked for bookings
CREATE TABLE IF NOT EXISTS blocked_dates (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    blocked_date DATE NOT NULL UNIQUE,
    reason TEXT,
    created_by INTEGER,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (created_by) REFERENCES users(id)
);

-- Create index for faster date lookups
CREATE INDEX IF NOT EXISTS idx_blocked_dates_date ON blocked_dates(blocked_date);

-- Booking Configuration Table
CREATE TABLE IF NOT EXISTS booking_config (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    config_key TEXT UNIQUE NOT NULL,
    config_value TEXT NOT NULL,
    description TEXT,
    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

-- Insert default booking configuration
INSERT OR IGNORE INTO booking_config (config_key, config_value, description) VALUES
('min_advance_hours', '24', 'Minimum hours in advance required for bookings (default: 24 hours)'),
('allow_same_day_booking', '0', 'Allow same-day bookings (0 = No, 1 = Yes)');
