-- Add location_settings table if it doesn't exist
CREATE TABLE IF NOT EXISTS location_settings (
    id INT PRIMARY KEY AUTO_INCREMENT,
    setting_name VARCHAR(100) NOT NULL UNIQUE,
    latitude DECIMAL(10, 8) NOT NULL,
    longitude DECIMAL(11, 8) NOT NULL,
    radius_meter INT NOT NULL DEFAULT 500,
    is_active BOOLEAN DEFAULT TRUE,
    description TEXT,
    created_by INT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL
);

-- Insert default hospital location if it doesn't exist
INSERT IGNORE INTO location_settings (setting_name, latitude, longitude, radius_meter, description, created_by) VALUES
('RSUD Dr. Albert H. Torey - Main', -7.250445, 112.768845, 500, 'Lokasi utama rumah sakit dengan radius 500 meter', 1);
