<?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>
			CREATE TABLE IF NOT EXISTS deregistration.data_from_gis_ervu (
				data_from_gis_ervu_id bigserial NOT NULL,
				recruitment_id varchar(36) NOT NULL,
				update_date timestamp DEFAULT now() NOT NULL,
				info_date date NOT NULL,
				count_collated_data int8 DEFAULT 0 NOT NULL,
				count_collated int8 DEFAULT 0 NOT NULL,
				CONSTRAINT data_from_gis_ervu_pkey PRIMARY KEY (data_from_gis_ervu_id),
				CONSTRAINT fk_data_from_gis_ervu_recruitment_id FOREIGN KEY (recruitment_id) REFERENCES metrics.recruitment(id)
			);
			CREATE INDEX IF NOT EXISTS idx_data_from_gis_ervu_date ON deregistration.data_from_gis_ervu USING btree (info_date);
			CREATE INDEX IF NOT EXISTS idx_data_from_gis_ervu_recr ON deregistration.data_from_gis_ervu USING btree (recruitment_id);
			CREATE INDEX IF NOT EXISTS idx_data_from_gis_ervu_recr_date ON deregistration.data_from_gis_ervu USING btree (recruitment_id, info_date);

			COMMENT ON COLUMN deregistration.data_from_gis_ervu.count_collated_data IS 'данных гражданина сверено с данными ГИС ЕРВУ';
			COMMENT ON COLUMN deregistration.data_from_gis_ervu.count_collated IS 'записей сопоставлено с ГИС ЕРВУ';

			ALTER TABLE IF EXISTS deregistration.data_from_gis_ervu OWNER TO ervu_business_metrics;
		</sql>
	</changeSet>
</databaseChangeLog>