-- Update column types to be more flexible
ALTER TABLE hbcc_providers
    ALTER COLUMN hours_per_day TYPE VARCHAR(50),
    ALTER COLUMN days_per_week TYPE VARCHAR(255),
    ALTER COLUMN years_operating TYPE VARCHAR(50),
    ALTER COLUMN age_group_children_count TYPE VARCHAR(50),
    ALTER COLUMN special_needs_children_count TYPE VARCHAR(50),
    ALTER COLUMN estimated_daily_income TYPE VARCHAR(50),
    ALTER COLUMN typical_daily_expense TYPE VARCHAR(50),
    ALTER COLUMN interviewee_age TYPE VARCHAR(50),
    ALTER COLUMN number_of_children TYPE VARCHAR(50);

-- Add columns that might be missing
DO $$ 
BEGIN
    BEGIN
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS expense_food BOOLEAN DEFAULT FALSE;
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS expense_activities_supplies BOOLEAN DEFAULT FALSE;
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS expense_utilities BOOLEAN DEFAULT FALSE;
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS expense_rentlease BOOLEAN DEFAULT FALSE;
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS other_expenses BOOLEAN DEFAULT FALSE;
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS affordability_food VARCHAR(255);
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS affordability_activitiessupplies VARCHAR(255);
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS affordability_utilities VARCHAR(255);
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS affordability_rentlease VARCHAR(255);
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS up_to_date_vaccinations BOOLEAN DEFAULT FALSE;
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS up_to_date_growth_monitoring BOOLEAN DEFAULT FALSE;
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS up_to_date_deworming BOOLEAN DEFAULT FALSE;
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS up_to_date_vas BOOLEAN DEFAULT FALSE;
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS up_to_date_other_health_services BOOLEAN DEFAULT FALSE;
        ALTER TABLE hbcc_providers ADD COLUMN IF NOT EXISTS status VARCHAR(50) DEFAULT 'pending';
    EXCEPTION
        WHEN duplicate_column THEN 
            -- Do nothing, column already exists
    END;
END $$;
