DO $$
BEGIN
    -- Add fecha_inicio if it doesn't exist
    IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'clases' AND column_name = 'fecha_inicio') THEN
        ALTER TABLE clases ADD COLUMN fecha_inicio DATE NOT NULL DEFAULT CURRENT_DATE;
    END IF;

    -- Add fecha_fin if it doesn't exist
    IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'clases' AND column_name = 'fecha_fin') THEN
        ALTER TABLE clases ADD COLUMN fecha_fin DATE NULL;
    END IF;
END $$;
