<?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 table</comment>
		<sql>
			CREATE TABLE IF NOT EXISTS forecast.reporting_military_commissariat (
				reporting_military_commissariat_id bigserial NOT NULL,
				recruitment_id uuid NOT NULL,
				recording_date date DEFAULT now() NOT NULL,
				"schema" varchar(64) DEFAULT 'empty'::character varying NOT NULL,
				subpoenaed_appear numeric NULL,
				missed_deadline numeric NULL,
				missed_deadline_reason numeric NULL,
				subpoenas_issued numeric NULL,
				retrieved_7_days numeric NULL,
				CONSTRAINT pk_reporting_military_commissariat PRIMARY KEY (reporting_military_commissariat_id)
			);

			ALTER TABLE IF EXISTS forecast.reporting_military_commissariat OWNER TO "ervu-dashboard";	

			COMMENT ON TABLE forecast.reporting_military_commissariat IS 'Явка в Военный комиссариат';

			COMMENT ON COLUMN forecast.reporting_military_commissariat.subpoenaed_appear IS 'Явились по повесткам'; 
			COMMENT ON COLUMN forecast.reporting_military_commissariat.missed_deadline IS 'Не явились в срок'; 
			COMMENT ON COLUMN forecast.reporting_military_commissariat.missed_deadline_reason IS 'Не явились по уважительной причине'; 
			COMMENT ON COLUMN forecast.reporting_military_commissariat.subpoenas_issued IS 'Вручено повесток'; 
			COMMENT ON COLUMN forecast.reporting_military_commissariat.retrieved_7_days IS 'Вручено через 7 дней(автоматически)'; 
		</sql>
	</changeSet>
	
	<changeSet id="0002" author="saliakhov">
        <comment>create table</comment>
		<sql>
			CREATE TABLE IF NOT EXISTS forecast.enroll (
				enroll_id bigserial NOT NULL,
				recruitment_id uuid NOT NULL,
				recording_date date DEFAULT now() NOT NULL,
				"schema" varchar(64) DEFAULT 'empty'::character varying NOT NULL,
				study numeric NULL,
				work numeric NULL,
				unemployed numeric NULL,
				count_17_years numeric NULL,
				count_18_26_years numeric NULL,
				count_27_30_years numeric NULL,
				count_31_35_years numeric NULL,
				count_36_40_years numeric NULL,
				count_41_45_years numeric NULL,
				count_46_50_years numeric NULL,
				count_51_years numeric NULL,
				CONSTRAINT pk_enroll PRIMARY KEY (enroll_id)
			);

			ALTER TABLE IF EXISTS forecast.enroll OWNER TO "ervu-dashboard";	

			COMMENT ON TABLE forecast.enroll IS 'Подлежат постановке на учет';

			COMMENT ON COLUMN forecast.enroll.study IS 'Учатся';    
			COMMENT ON COLUMN forecast.enroll.work IS 'Работают'; 
			COMMENT ON COLUMN forecast.enroll.unemployed IS 'Безработные'; 
			COMMENT ON COLUMN forecast.enroll.count_17_years IS '17 л.'; 
			COMMENT ON COLUMN forecast.enroll.count_18_26_years IS '18-26 л.'; 
			COMMENT ON COLUMN forecast.enroll.count_27_30_years IS '27-30 л.'; 
			COMMENT ON COLUMN forecast.enroll.count_31_35_years IS '31-35 л.'; 
			COMMENT ON COLUMN forecast.enroll.count_36_40_years IS '36-40 л.'; 
			COMMENT ON COLUMN forecast.enroll.count_41_45_years IS '41-45 л.'; 
			COMMENT ON COLUMN forecast.enroll.count_46_50_years IS '46-50 л.'; 
			COMMENT ON COLUMN forecast.enroll.count_51_years IS '51+ л.'; 
		</sql>
	</changeSet>
	
	<changeSet id="0003" author="saliakhov">
        <comment>create table</comment>
		<sql>
			CREATE TABLE IF NOT EXISTS forecast.temporary_measures (
				temporary_measures_id bigserial NOT NULL,
				recruitment_id uuid NOT NULL,
				recording_date date DEFAULT now() NOT NULL,
				"schema" varchar(64) DEFAULT 'empty'::character varying NOT NULL,
				introduction_provisional_measures numeric NULL,
				lifting_provisional_measures numeric NULL,
				CONSTRAINT pk_temporary_measures PRIMARY KEY (temporary_measures_id)
			);

			ALTER TABLE IF EXISTS forecast.temporary_measures OWNER TO "ervu-dashboard";	
				
			COMMENT ON TABLE forecast.temporary_measures IS 'Решения о принятии и снятии временных мер';

			COMMENT ON COLUMN forecast.temporary_measures.introduction_provisional_measures IS 'Введение временных мер';    
			COMMENT ON COLUMN forecast.temporary_measures.lifting_provisional_measures IS 'Снятие временных мер';
		</sql>
	</changeSet>
	
	<changeSet id="0004" author="saliakhov">
        <comment>create table</comment>
		<sql>
			CREATE TABLE IF NOT EXISTS forecast.appeals (
				appeals_id bigserial NOT NULL,
				recruitment_id uuid NOT NULL,
				recording_date date DEFAULT now() NOT NULL,
				"schema" varchar(64) DEFAULT 'empty'::character varying NOT NULL,
				resolved_appeals numeric NULL,
				document_retrieval numeric NULL,
				retraction_complaint numeric NULL,
				disagreement_decision numeric NULL,
				incorrect_information numeric NULL,
				maintaining_military_records numeric NULL,
				conscription numeric NULL,
				temporary_measures numeric NULL,
				CONSTRAINT pk_appeals PRIMARY KEY (appeals_id)
			);

			ALTER TABLE IF EXISTS forecast.appeals OWNER TO "ervu-dashboard";	

			COMMENT ON TABLE forecast.appeals IS 'Обжалования';

			COMMENT ON COLUMN forecast.appeals.resolved_appeals IS 'Решенные обжалования';    
			COMMENT ON COLUMN forecast.appeals.document_retrieval IS 'Досыл документов'; 
			COMMENT ON COLUMN forecast.appeals.retraction_complaint IS 'Отзыв жалобы'; 
			COMMENT ON COLUMN forecast.appeals.disagreement_decision IS 'Несогласие с решением'; 
			COMMENT ON COLUMN forecast.appeals.incorrect_information IS 'Некорректные данные'; 
			COMMENT ON COLUMN forecast.appeals.maintaining_military_records IS 'Ведение воинского учета'; 
			COMMENT ON COLUMN forecast.appeals.conscription IS 'Призыв на службу'; 
			COMMENT ON COLUMN forecast.appeals.temporary_measures IS 'Временные меры';
		</sql>
	</changeSet>
	
	<changeSet id="0005" author="saliakhov">
        <comment>create table</comment>
		<sql>
			CREATE TABLE IF NOT EXISTS forecast.deferment_conscription (
				deferment_conscription_id bigserial NOT NULL,
				recruitment_id uuid NOT NULL,
				recording_date date DEFAULT now() NOT NULL,
				"schema" varchar(64) DEFAULT 'empty'::character varying NOT NULL,
				eligible_deferment numeric NULL,
				deferment_granted numeric NULL,
				CONSTRAINT pk_deferment_conscription PRIMARY KEY (deferment_conscription_id)
			);

			ALTER TABLE IF EXISTS forecast.deferment_conscription OWNER TO "ervu-dashboard";	
				
			COMMENT ON TABLE forecast.deferment_conscription IS 'Отсрочка от призыва';

			COMMENT ON COLUMN forecast.deferment_conscription.eligible_deferment IS 'Имеют право на отсрочку';    
			COMMENT ON COLUMN forecast.deferment_conscription.deferment_granted IS 'Предоставлена отсрочка'; 
		</sql>
	</changeSet>
</databaseChangeLog>