DO
$migration$
begin
    if not exists(select * from INFORMATION_SCHEMA.COLUMNS where table_name = 't_plan_cut_dictionary' and table_schema = 'ies' and column_name = 'cutplansection')
    then
    begin
        ALTER TABLE IES.T_PLAN_CUT_DICTIONARY ADD "cutplansection" uuid NULL;
        ALTER TABLE IES.T_PLAN_CUT_DICTIONARY ADD CONSTRAINT FK_T_PLAN_SECTION_T_PLAN_CUT_DICTIONARY_CutPlanSection
        FOREIGN KEY("cutplansection") REFERENCES IES.T_PLAN_SECTION (PlanSectionID);
    end;
    end if;
end;
$migration$;
