<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
					  

	
	<changeSet id="0001" author="saliakhov">
        <comment>create column</comment>
		<sql>
			ALTER TABLE init_registration_info.incoming_creating_records ADD COLUMN IF NOT EXISTS count_records_uploaded int8 DEFAULT 0 NOT NULL;
			ALTER TABLE init_registration_info.incoming_creating_records ADD COLUMN IF NOT EXISTS count_records_created int8 DEFAULT 0 NOT NULL;
			COMMENT ON COLUMN init_registration_info.incoming_creating_records.count_records_uploaded IS 'Количество записей, загруженных в ГИС ЕРВУ';
			COMMENT ON COLUMN init_registration_info.incoming_creating_records.count_records_created IS 'Количество созданных записей гражданина';

			ALTER TABLE admin_indicators.user_analysis ADD COLUMN IF NOT EXISTS recruitment_id varchar(36) NOT NULL;
		</sql>
	</changeSet>
	
	<changeSet id="0002" author="saliakhov">
        <comment>create column and view</comment>
		<sql>
			ALTER TABLE metrics.convert_info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_send int8 DEFAULT 0 NOT NULL;
			ALTER TABLE metrics.convert_info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_delivered int8 DEFAULT 0 NOT NULL;
			COMMENT ON COLUMN metrics.convert_info_sent_to_lk_epgu.count_exceeded_send IS 'Превышено время ожидания отправки уведомления';
			COMMENT ON COLUMN metrics.convert_info_sent_to_lk_epgu.count_exceeded_delivered IS 'Превышено время ожидания доставки уведомления';

			CREATE OR REPLACE VIEW metrics.view_convert_info_sent_to_lk_epgu
			AS SELECT convert_info_sent_to_lk_epgu.convert_info_sent_to_lk_epgu_id,
				COALESCE(round(convert_info_sent_to_lk_epgu.count_status_formed::numeric * 100::numeric / NULLIF((convert_info_sent_to_lk_epgu.count_status_formed + convert_info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_formed,
				COALESCE(round(convert_info_sent_to_lk_epgu.count_status_not_formed::numeric * 100::numeric / NULLIF((convert_info_sent_to_lk_epgu.count_status_formed + convert_info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_not_formed,
				COALESCE(round(convert_info_sent_to_lk_epgu.count_sended::numeric * 100::numeric / NULLIF((convert_info_sent_to_lk_epgu.count_status_formed + convert_info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_sended,
				COALESCE(round(convert_info_sent_to_lk_epgu.count_delivered::numeric * 100::numeric / NULLIF((convert_info_sent_to_lk_epgu.count_status_formed + convert_info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_delivered,
				COALESCE(round(convert_info_sent_to_lk_epgu.count_error::numeric * 100::numeric / NULLIF((convert_info_sent_to_lk_epgu.count_status_formed + convert_info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_error,
				COALESCE(round(convert_info_sent_to_lk_epgu.count_viewed::numeric * 100::numeric / NULLIF((convert_info_sent_to_lk_epgu.count_status_formed + convert_info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_viewed,
				COALESCE(round(convert_info_sent_to_lk_epgu.count_not_viewed::numeric * 100::numeric / NULLIF((convert_info_sent_to_lk_epgu.count_status_formed + convert_info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_not_viewed,
				convert_info_sent_to_lk_epgu.count_status_formed + convert_info_sent_to_lk_epgu.count_status_not_formed AS count_all,
				COALESCE(round(convert_info_sent_to_lk_epgu.count_exceeded_send::numeric * 100::numeric / NULLIF((convert_info_sent_to_lk_epgu.count_status_formed + convert_info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_send,
				COALESCE(round(convert_info_sent_to_lk_epgu.count_exceeded_delivered::numeric * 100::numeric / NULLIF((convert_info_sent_to_lk_epgu.count_status_formed + convert_info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_delivered
			   FROM metrics.convert_info_sent_to_lk_epgu;



			ALTER TABLE init_registration_info.info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_send int8 DEFAULT 0 NOT NULL;
			ALTER TABLE init_registration_info.info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_delivered int8 DEFAULT 0 NOT NULL;
			COMMENT ON COLUMN init_registration_info.info_sent_to_lk_epgu.count_exceeded_send IS 'Превышено время ожидания отправки уведомления';
			COMMENT ON COLUMN init_registration_info.info_sent_to_lk_epgu.count_exceeded_delivered IS 'Превышено время ожидания доставки уведомления';

			CREATE OR REPLACE VIEW init_registration_info.view_info_sent_to_lk_epgu
			AS SELECT info_sent_to_lk_epgu.info_sent_to_lk_epgu_id,
				COALESCE(round(info_sent_to_lk_epgu.count_status_formed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_formed,
				COALESCE(round(info_sent_to_lk_epgu.count_status_not_formed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_not_formed,
				COALESCE(round(info_sent_to_lk_epgu.count_sended::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_sended,
				COALESCE(round(info_sent_to_lk_epgu.count_delivered::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_delivered,
				COALESCE(round(info_sent_to_lk_epgu.count_error::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_error,
				COALESCE(round(info_sent_to_lk_epgu.count_viewed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_viewed,
				COALESCE(round(info_sent_to_lk_epgu.count_not_viewed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_not_viewed,
				info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed AS count_all,
				COALESCE(round(info_sent_to_lk_epgu.count_exceeded_send::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_send,
				COALESCE(round(info_sent_to_lk_epgu.count_exceeded_delivered::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_delivered
			   FROM init_registration_info.info_sent_to_lk_epgu;


			ALTER TABLE actualization.info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_send int8 DEFAULT 0 NOT NULL;
			ALTER TABLE actualization.info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_delivered int8 DEFAULT 0 NOT NULL;
			COMMENT ON COLUMN actualization.info_sent_to_lk_epgu.count_exceeded_send IS 'Превышено время ожидания отправки уведомления';
			COMMENT ON COLUMN actualization.info_sent_to_lk_epgu.count_exceeded_delivered IS 'Превышено время ожидания доставки уведомления';

			CREATE OR REPLACE VIEW actualization.view_info_sent_to_lk_epgu
			AS SELECT info_sent_to_lk_epgu.info_sent_to_lk_epgu_id,
				COALESCE(round(info_sent_to_lk_epgu.count_status_formed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_formed,
				COALESCE(round(info_sent_to_lk_epgu.count_status_not_formed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_not_formed,
				COALESCE(round(info_sent_to_lk_epgu.count_sended::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_sended,
				COALESCE(round(info_sent_to_lk_epgu.count_delivered::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_delivered,
				COALESCE(round(info_sent_to_lk_epgu.count_error::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_error,
				COALESCE(round(info_sent_to_lk_epgu.count_viewed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_viewed,
				COALESCE(round(info_sent_to_lk_epgu.count_not_viewed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_not_viewed,
				info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed AS count_all,
				COALESCE(round(info_sent_to_lk_epgu.count_exceeded_send::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_send,
				COALESCE(round(info_sent_to_lk_epgu.count_exceeded_delivered::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_delivered
			   FROM actualization.info_sent_to_lk_epgu;




			ALTER TABLE summonses_list.info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_send int8 DEFAULT 0 NOT NULL;
			ALTER TABLE summonses_list.info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_delivered int8 DEFAULT 0 NOT NULL;
			COMMENT ON COLUMN summonses_list.info_sent_to_lk_epgu.count_exceeded_send IS 'Превышено время ожидания отправки уведомления';
			COMMENT ON COLUMN summonses_list.info_sent_to_lk_epgu.count_exceeded_delivered IS 'Превышено время ожидания доставки уведомления';

			CREATE OR REPLACE VIEW summonses_list.view_info_sent_to_lk_epgu
			AS SELECT info_sent_to_lk_epgu.info_sent_to_lk_epgu_id,
				COALESCE(round(info_sent_to_lk_epgu.count_status_formed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_formed,
				COALESCE(round(info_sent_to_lk_epgu.count_status_not_formed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_not_formed,
				COALESCE(round(info_sent_to_lk_epgu.count_sended::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_sended,
				COALESCE(round(info_sent_to_lk_epgu.count_delivered::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_delivered,
				COALESCE(round(info_sent_to_lk_epgu.count_error::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_error,
				COALESCE(round(info_sent_to_lk_epgu.count_viewed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_viewed,
				COALESCE(round(info_sent_to_lk_epgu.count_not_viewed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_not_viewed,
				info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed AS count_all,
				COALESCE(round(info_sent_to_lk_epgu.count_exceeded_send::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_send,
				COALESCE(round(info_sent_to_lk_epgu.count_exceeded_delivered::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_delivered
			   FROM summonses_list.info_sent_to_lk_epgu;




			ALTER TABLE deregistration.info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_send int8 DEFAULT 0 NOT NULL;
			ALTER TABLE deregistration.info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_delivered int8 DEFAULT 0 NOT NULL;
			COMMENT ON COLUMN deregistration.info_sent_to_lk_epgu.count_exceeded_send IS 'Превышено время ожидания отправки уведомления';
			COMMENT ON COLUMN deregistration.info_sent_to_lk_epgu.count_exceeded_delivered IS 'Превышено время ожидания доставки уведомления';

			CREATE OR REPLACE VIEW deregistration.view_info_sent_to_lk_epgu
			AS SELECT info_sent_to_lk_epgu.info_sent_to_lk_epgu_id,
				COALESCE(round(info_sent_to_lk_epgu.count_status_formed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_formed,
				COALESCE(round(info_sent_to_lk_epgu.count_status_not_formed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_not_formed,
				COALESCE(round(info_sent_to_lk_epgu.count_sended::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_sended,
				COALESCE(round(info_sent_to_lk_epgu.count_delivered::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_delivered,
				COALESCE(round(info_sent_to_lk_epgu.count_error::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_error,
				COALESCE(round(info_sent_to_lk_epgu.count_viewed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_viewed,
				COALESCE(round(info_sent_to_lk_epgu.count_not_viewed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_not_viewed,
				info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed AS count_all,
				COALESCE(round(info_sent_to_lk_epgu.count_exceeded_send::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_send,
				COALESCE(round(info_sent_to_lk_epgu.count_exceeded_delivered::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_delivered
			   FROM deregistration.info_sent_to_lk_epgu;



			ALTER TABLE registration_change_address.info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_send int8 DEFAULT 0 NOT NULL;
			ALTER TABLE registration_change_address.info_sent_to_lk_epgu ADD COLUMN IF NOT EXISTS count_exceeded_delivered int8 DEFAULT 0 NOT NULL;
			COMMENT ON COLUMN registration_change_address.info_sent_to_lk_epgu.count_exceeded_send IS 'Превышено время ожидания отправки уведомления';
			COMMENT ON COLUMN registration_change_address.info_sent_to_lk_epgu.count_exceeded_delivered IS 'Превышено время ожидания доставки уведомления';

			CREATE OR REPLACE VIEW registration_change_address.view_info_sent_to_lk_epgu
			AS SELECT info_sent_to_lk_epgu.info_sent_to_lk_epgu_id,
				COALESCE(round(info_sent_to_lk_epgu.count_status_formed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_formed,
				COALESCE(round(info_sent_to_lk_epgu.count_status_not_formed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_status_not_formed,
				COALESCE(round(info_sent_to_lk_epgu.count_sended::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_sended,
				COALESCE(round(info_sent_to_lk_epgu.count_delivered::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_delivered,
				COALESCE(round(info_sent_to_lk_epgu.count_error::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_error,
				COALESCE(round(info_sent_to_lk_epgu.count_viewed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_viewed,
				COALESCE(round(info_sent_to_lk_epgu.count_not_viewed::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_not_viewed,
				info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed AS count_all,
				COALESCE(round(info_sent_to_lk_epgu.count_exceeded_send::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_send,
				COALESCE(round(info_sent_to_lk_epgu.count_exceeded_delivered::numeric * 100::numeric / NULLIF((info_sent_to_lk_epgu.count_status_formed + info_sent_to_lk_epgu.count_status_not_formed)::numeric, 0::numeric)), 0::numeric) AS percent_exceeded_delivered
			   FROM registration_change_address.info_sent_to_lk_epgu;
		</sql>
	</changeSet>
	
	<changeSet id="0003" author="saliakhov">
        <comment>create column</comment>
		<sql>
			CREATE TABLE IF NOT EXISTS deregistration.generated_solutions (
				generated_solutions_id bigserial NOT NULL,
				recruitment_id varchar(36) NOT NULL,
				update_date timestamp DEFAULT now() NOT NULL,
				info_date date NOT NULL,
				count_arrived_death_reason int8 DEFAULT 0 NOT NULL,
				count_arrived_age_limit int8 DEFAULT 0 NOT NULL,
				CONSTRAINT generated_solutions_pkey PRIMARY KEY (generated_solutions_id),
				CONSTRAINT fk_generated_solutions_recruitment_id FOREIGN KEY (recruitment_id) REFERENCES metrics.recruitment(id)
			);
			CREATE INDEX IF NOT EXISTS idx_generated_solutions_date ON deregistration.generated_solutions USING btree (info_date);
			CREATE INDEX IF NOT EXISTS idx_generated_solutions_recr ON deregistration.generated_solutions USING btree (recruitment_id);
			CREATE INDEX IF NOT EXISTS idx_generated_solutions_recr_date ON deregistration.generated_solutions USING btree (recruitment_id, info_date);

			COMMENT ON TABLE deregistration.generated_solutions IS 'Снятие с воинского учета. Сформированные решения';
			COMMENT ON COLUMN deregistration.generated_solutions.count_arrived_death_reason IS 'поступило по причине смерти';
			COMMENT ON COLUMN deregistration.generated_solutions.count_arrived_age_limit IS 'поступило по предельному возрасту';

			ALTER TABLE IF EXISTS deregistration.generated_solutions OWNER TO ervu_business_metrics;

			CREATE OR REPLACE VIEW deregistration.view_generated_solutions
			AS SELECT generated_solutions.generated_solutions_id,
				generated_solutions.count_arrived_death_reason + generated_solutions.count_arrived_age_limit AS count_arrived_all,
				round(generated_solutions.count_arrived_death_reason::numeric * 100::numeric / (generated_solutions.count_arrived_death_reason + generated_solutions.count_arrived_age_limit)::numeric) AS percent_arrived_death_reason,
				round(generated_solutions.count_arrived_age_limit::numeric * 100::numeric / (generated_solutions.count_arrived_death_reason + generated_solutions.count_arrived_age_limit)::numeric) AS percent_arrived_age_limit
			   FROM deregistration.generated_solutions;

			ALTER TABLE deregistration.view_decisions_signing OWNER TO ervu_business_metrics;
			
			ALTER TABLE metrics.citizen_appeals ADD COLUMN IF NOT EXISTS average_response_time int8 DEFAULT 0 NOT NULL;
			COMMENT ON COLUMN metrics.citizen_appeals.average_response_time IS 'Средний срок ответа';
			
			ALTER TABLE registration_change_address.change_data_personal_visit ADD COLUMN IF NOT EXISTS count_records_edited int8 DEFAULT 0 NOT NULL;
			COMMENT ON COLUMN registration_change_address.change_data_personal_visit.count_records_edited IS 'Записей гражданина отрекдактировано';

			ALTER TABLE init_registration_info.incoming_creating_records ADD COLUMN IF NOT EXISTS count_collated_data int8 DEFAULT 0 NOT NULL;
			ALTER TABLE init_registration_info.incoming_creating_records ADD COLUMN IF NOT EXISTS count_collated int8 DEFAULT 0 NOT NULL;
			ALTER TABLE init_registration_info.incoming_creating_records ADD COLUMN IF NOT EXISTS count_deregistered_declaration int8 DEFAULT 0 NOT NULL;
			COMMENT ON COLUMN init_registration_info.incoming_creating_records.count_collated_data IS 'данных гражданина сверено с данными ГИС ЕРВУ';
			COMMENT ON COLUMN init_registration_info.incoming_creating_records.count_collated IS 'записей сопоставлено с ГИС ЕРВУ';
			COMMENT ON COLUMN init_registration_info.incoming_creating_records.count_deregistered_declaration IS 'граждан снято с учета по заявлению с ЕПГУ';
		</sql>
	</changeSet>
</databaseChangeLog>