DO $$ 
begin
	
	if(not exists(
		SELECT *
	  	FROM information_schema.columns
	 	WHERE table_schema = 'akuz' AND table_name   = 't_rds_synchronisation_errors' and column_name = 'hasbytecontent' ))
	then
		ALTER TABLE akuz.t_rds_synchronisation_errors ADD hasbytecontent boolean GENERATED ALWAYS AS ((case when ByteContent IS NOT NULL then '1' else '0' end)::boolean) STORED;
	end if;
	
	if(not exists(
		SELECT *
	  	FROM information_schema.columns
	 	WHERE table_schema = 'akuz' AND table_name   = 't_rds_synchronisation_errors' and column_name = 'hastextcontent' ))
	then
		ALTER TABLE akuz.t_rds_synchronisation_errors ADD HasTextContent boolean GENERATED ALWAYS AS ((case when TextContent IS NOT NULL then '1' else '0' end)::boolean) STORED;
	end if;
	
	if(not exists(
		SELECT *
	  	FROM information_schema.columns
	 	WHERE table_schema = 'akuz' AND table_name   = 't_recipe' and column_name = 'year' ))
	then
		ALTER TABLE akuz.t_recipe ADD "year" integer GENERATED ALWAYS AS (date_part('year',recipedate)) STORED;
	end if;
	
	if(not exists(
		SELECT *
	  	FROM information_schema.columns
	 	WHERE table_schema = 'akuz' AND table_name   = 't_calc_link_work_factor' and column_name = 'examinationfactors' ))
	then
		ALTER TABLE akuz.t_calc_link_work_factor ADD ExaminationFactors varchar(72) GENERATED ALWAYS AS (ExaminationRequest::varchar(36) + BaseExaminationWorkFactor::varchar(36)) STORED;
	end if;
	
	if(not exists(
		SELECT *
	  	FROM information_schema.columns
	 	WHERE table_schema = 'akuz' AND table_name   = 't_calc_link_medical_service' and column_name = 'examinationservices' ))
	then
		ALTER TABLE akuz.t_calc_link_medical_service ADD ExaminationServices varchar(72) GENERATED ALWAYS AS (ExaminationRequest::varchar(36) + MedicalService::varchar(36)) STORED;
	end if;
end;
$$
