BEGIN;

DO $$
    BEGIN
        BEGIN
            ALTER TABLE routes ADD COLUMN connection integer NOT NULL DEFAULT 0;
        EXCEPTION
            WHEN duplicate_column THEN
            --do nothing
        END;
    END;
$$;

UPDATE template_rules SET rule_mode='auto';

COMMIT;
