DO $$ 
begin
	
	if( not exists(
		SELECT *
	  	FROM information_schema.columns
	 	WHERE table_schema = 'aps' AND table_name   = 't_rds_synchronisation_errors' and column_name = 'hasbytecontent' ))
	then

		ALTER TABLE aps.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(exists(
		SELECT *
	  	FROM information_schema.columns
	 	WHERE table_schema = 'aps' AND table_name   = 't_rds_synchronisation_errors' and column_name = 'hastextcontent' ))
	then
	
		ALTER TABLE aps.t_rds_synchronisation_errors DROP COLUMN hastextcontent;
	end if;
end;
$$
