<?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 ervu_dashboard.temporary_measures ADD COLUMN IF NOT EXISTS date_application timestamp NULL;

			COMMENT ON COLUMN ervu_dashboard.temporary_measures.date_application IS 'Дата применения временной меры';
			
			
			ALTER TABLE ervu_dashboard.subpoena ADD COLUMN IF NOT EXISTS date_public_register time NULL;
			ALTER TABLE ervu_dashboard.subpoena ADD COLUMN IF NOT EXISTS visit_date_true time NULL;
			ALTER TABLE ervu_dashboard.subpoena ADD COLUMN IF NOT EXISTS date_recognition_reason time NULL;
			ALTER TABLE ervu_dashboard.subpoena ADD COLUMN IF NOT EXISTS sign_sending_info_good_reason bool NULL;
			ALTER TABLE ervu_dashboard.subpoena ADD COLUMN IF NOT EXISTS date_sending_good_reason time NULL;
			ALTER TABLE ervu_dashboard.subpoena ADD COLUMN IF NOT EXISTS info_not_visit_recognition_good_reason varchar NULL;
			ALTER TABLE ervu_dashboard.subpoena ADD COLUMN IF NOT EXISTS subpoena_directed_fact text NULL;
			
			COMMENT ON COLUMN ervu_dashboard.subpoena.date_public_register IS 'Дата размещения в общедоступном реестре направленных (врученных) повесток';
			COMMENT ON COLUMN ervu_dashboard.subpoena.visit_date_true IS 'Дата явки (в случае явки)';
			COMMENT ON COLUMN ervu_dashboard.subpoena.date_recognition_reason IS 'Дата признания причины неявки в военный комиссариат по повестке уважительной';
			COMMENT ON COLUMN ervu_dashboard.subpoena.sign_sending_info_good_reason IS 'Признак направления сведений о неявке по уважительной причине';
			COMMENT ON COLUMN ervu_dashboard.subpoena.date_sending_good_reason IS 'Дата направления сведений об уважительной причине неявки';
			COMMENT ON COLUMN ervu_dashboard.subpoena.info_not_visit_recognition_good_reason IS 'Сведения о признании причины неявки в военный комиссариат по повестке уважительной';
			COMMENT ON COLUMN ervu_dashboard.subpoena.subpoena_directed_fact IS 'Факт направления повестки';
		</sql>
	</changeSet>
	
	<changeSet id="0002" author="saliakhov">
        <comment>create table</comment>
		<sql>
			CREATE TABLE IF NOT EXISTS ervu_dashboard.citizen_sports_categories (
				citizen_sports_categories_id bigserial NOT NULL,
				recruit_id uuid NOT NULL,
				sports_category_name varchar NULL,
				type_sport varchar NULL,
				start_date_category date NULL,
				end_date_category date NULL,
				sport_title varchar NULL,
				start_date_title date NULL,
				having_sports_category_title varchar NULL,
				CONSTRAINT pk_citizen_sports_categories PRIMARY KEY (citizen_sports_categories_id)
			);

			ALTER TABLE IF EXISTS ervu_dashboard.citizen_sports_categories OWNER TO "ervu-dashboard";

			COMMENT ON TABLE ervu_dashboard.citizen_sports_categories IS 'Сведения о присвоении спортивных разрядов и званий';

			COMMENT ON COLUMN ervu_dashboard.citizen_sports_categories.recruit_id IS 'ссылка на гражданина (citizen)';
			COMMENT ON COLUMN ervu_dashboard.citizen_sports_categories.sports_category_name IS 'Спортивный разряд';
			COMMENT ON COLUMN ervu_dashboard.citizen_sports_categories.type_sport IS 'Вид спорта';
			COMMENT ON COLUMN ervu_dashboard.citizen_sports_categories.start_date_category IS 'Дата присвоения спортивного разряда';
			COMMENT ON COLUMN ervu_dashboard.citizen_sports_categories.end_date_category IS 'Дата действия спортивного разряда';
			COMMENT ON COLUMN ervu_dashboard.citizen_sports_categories.sport_title IS 'Спортивное звание';
			COMMENT ON COLUMN ervu_dashboard.citizen_sports_categories.start_date_title IS 'Дата присвоения спортивного звания';
			COMMENT ON COLUMN ervu_dashboard.citizen_sports_categories.having_sports_category_title IS 'Наличие спортивного разряда или спортивного звания';
		</sql>
	</changeSet>	

	<changeSet id="0003" author="saliakhov">
        <comment>create table</comment>
		<sql>
			CREATE TABLE IF NOT EXISTS ervu_dashboard.citizen_criminal_record (
				citizen_criminal_record_id bigserial NOT NULL,
				recruit_id uuid NOT NULL,
				criminal_record_name varchar NULL,
				end_date_criminal_record date NULL,
				grounds_expunging varchar NULL,
				CONSTRAINT pk_citizen_criminal_record PRIMARY KEY (citizen_criminal_record_id)
			);

			ALTER TABLE IF EXISTS ervu_dashboard.citizen_criminal_record OWNER TO "ervu-dashboard";

			COMMENT ON TABLE ervu_dashboard.citizen_criminal_record IS 'Сведения о судимости';

			COMMENT ON COLUMN ervu_dashboard.citizen_criminal_record.recruit_id IS 'ссылка на гражданина (citizen)';
			COMMENT ON COLUMN ervu_dashboard.citizen_criminal_record.criminal_record_name IS 'Наименование судимости';
			COMMENT ON COLUMN ervu_dashboard.citizen_criminal_record.end_date_criminal_record IS 'Дата погашения или снятия судимости';
			COMMENT ON COLUMN ervu_dashboard.citizen_criminal_record.grounds_expunging IS 'Основание погашения или снятия судимости';
		</sql>
	</changeSet>

	<changeSet id="0004" author="saliakhov">
        <comment>create table</comment>
		<sql>
			CREATE TABLE IF NOT EXISTS ervu_dashboard.citizen_information_search (
				citizen_information_search_id bigserial NOT NULL,
				recruit_id uuid NOT NULL,
				name_organ_start_search varchar NULL,
				wanted_start_date timestamp NULL,
				article_criminal_code varchar NULL,
				wanted_end_date timestamp NULL,
				name_organ_end_search varchar NULL,
				grounds_stopping_search varchar NULL,
				CONSTRAINT pk_citizen_information_search PRIMARY KEY (citizen_information_search_id)
			);

			ALTER TABLE IF EXISTS ervu_dashboard.citizen_information_search OWNER TO "ervu-dashboard";

			COMMENT ON TABLE ervu_dashboard.citizen_information_search IS 'Сведения о розыске';

			COMMENT ON COLUMN ervu_dashboard.citizen_information_search.recruit_id IS 'ссылка на гражданина (citizen)';
			COMMENT ON COLUMN ervu_dashboard.citizen_information_search.name_organ_start_search IS 'Наименование органа, принявшего решение о розыске';
			COMMENT ON COLUMN ervu_dashboard.citizen_information_search.wanted_start_date IS 'Дата объявления в розыск';
			COMMENT ON COLUMN ervu_dashboard.citizen_information_search.article_criminal_code IS 'Пункт, часть, статья УК РФ';
			COMMENT ON COLUMN ervu_dashboard.citizen_information_search.wanted_end_date IS 'Дата прекращения розыска';
			COMMENT ON COLUMN ervu_dashboard.citizen_information_search.name_organ_end_search IS 'Наименование органа, прекратившего розыск';
			COMMENT ON COLUMN ervu_dashboard.citizen_information_search.grounds_stopping_search IS 'Основание прекращения розыска';
		</sql>
	</changeSet>	
</databaseChangeLog>