-- Add columns to appointments table
ALTER TABLE appointments ADD COLUMN IF NOT EXISTS nurse_id INT NULL;
ALTER TABLE appointments ADD COLUMN IF NOT EXISTS visit_type ENUM('Clinic', 'Home') DEFAULT 'Clinic';
ALTER TABLE appointments ADD COLUMN IF NOT EXISTS address TEXT NULL;
ALTER TABLE appointments ADD CONSTRAINT fk_appointment_nurse FOREIGN KEY (nurse_id) REFERENCES nurses(id) ON DELETE SET NULL;

-- Add columns to visits table
ALTER TABLE visits ADD COLUMN IF NOT EXISTS nurse_id INT NULL;
ALTER TABLE visits ADD COLUMN IF NOT EXISTS visit_type ENUM('Clinic', 'Home') DEFAULT 'Clinic';
ALTER TABLE visits ADD COLUMN IF NOT EXISTS address TEXT NULL;
ALTER TABLE visits ADD CONSTRAINT fk_visit_nurse FOREIGN KEY (nurse_id) REFERENCES nurses(id) ON DELETE SET NULL;
