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

  <changeSet id="0001" author="hairuulin.b" dbms="postgresql">
    <comment>add new table appeals.appeals_list</comment>
    <sql>
    CREATE TABLE IF NOT EXISTS appeals.appeals_list
		(
			"number" integer,
			epgu_num text COLLATE pg_catalog."default",
			source text COLLATE pg_catalog."default",
			region text COLLATE pg_catalog."default",
			category text COLLATE pg_catalog."default",
			subcategory text COLLATE pg_catalog."default",
			fact text COLLATE pg_catalog."default",
			incoming_org text COLLATE pg_catalog."default",
			current_org text COLLATE pg_catalog."default",
			incoming_date text COLLATE pg_catalog."default",
			plan_end_date text COLLATE pg_catalog."default",
			fact_end_date text COLLATE pg_catalog."default",
			stage text COLLATE pg_catalog."default",
			status text COLLATE pg_catalog."default",
			overdue text COLLATE pg_catalog."default",
			fast_track text COLLATE pg_catalog."default",
			fz text COLLATE pg_catalog."default",
			solution_type text COLLATE pg_catalog."default",
			sent_by_email_to_not_connected_foiv text COLLATE pg_catalog."default",
			response_evalution text COLLATE pg_catalog."default",
			reconsideration text COLLATE pg_catalog."default",
			coordinator_org text COLLATE pg_catalog."default",
			coordinator_fio text COLLATE pg_catalog."default",
			contractor_org text COLLATE pg_catalog."default",
			contractor_fio text COLLATE pg_catalog."default",
			head_org text COLLATE pg_catalog."default",
			head_fio text COLLATE pg_catalog."default",
			issue_date text COLLATE pg_catalog."default",
			upload_date timestamp without time zone
		)
		TABLESPACE pg_default;
		ALTER TABLE IF EXISTS appeals.appeals_list
			OWNER to "ervu-dashboard";
		COMMENT ON COLUMN appeals.appeals_list."number"
			IS 'Номер';
		COMMENT ON COLUMN appeals.appeals_list.epgu_num
			IS 'Номер ЕПГУ';
		COMMENT ON COLUMN appeals.appeals_list.source
			IS 'Источник';
		COMMENT ON COLUMN appeals.appeals_list.region
			IS 'Верхнеуровневый ЛКО';
		COMMENT ON COLUMN appeals.appeals_list.category
			IS 'Категория';
		COMMENT ON COLUMN appeals.appeals_list.subcategory
			IS 'Подкатегория';
		COMMENT ON COLUMN appeals.appeals_list.fact
			IS 'Факт';
		COMMENT ON COLUMN appeals.appeals_list.incoming_org
			IS 'Организация, в которую поступило сообщение';
		COMMENT ON COLUMN appeals.appeals_list.current_org
			IS 'Организация, в которой находится сообщение';
		COMMENT ON COLUMN appeals.appeals_list.incoming_date
			IS 'Дата поступления';
		COMMENT ON COLUMN appeals.appeals_list.plan_end_date
			IS 'Дата планируемого завершения работ';
		COMMENT ON COLUMN appeals.appeals_list.fact_end_date
			IS 'Дата фактического завершения работ';
		COMMENT ON COLUMN appeals.appeals_list.stage
			IS 'Стадия';
		COMMENT ON COLUMN appeals.appeals_list.status
			IS 'Статус';
		COMMENT ON COLUMN appeals.appeals_list.overdue
			IS 'Просрочено';
		COMMENT ON COLUMN appeals.appeals_list.fast_track
			IS 'Фаст-трек';
		COMMENT ON COLUMN appeals.appeals_list.fz
			IS 'ФЗ';
		COMMENT ON COLUMN appeals.appeals_list.solution_type
			IS 'Тип решения';
		COMMENT ON COLUMN appeals.appeals_list.sent_by_email_to_not_connected_foiv
			IS 'Направлено по email в ФОИВ, не подключенный к ПОС';
		COMMENT ON COLUMN appeals.appeals_list.response_evalution
			IS 'Оценка ответа заявителем';
		COMMENT ON COLUMN appeals.appeals_list.reconsideration
			IS 'Повторное рассмотрение';
		COMMENT ON COLUMN appeals.appeals_list.coordinator_org
			IS 'Организация координатора';
		COMMENT ON COLUMN appeals.appeals_list.coordinator_fio
			IS 'ФИО координатора';
		COMMENT ON COLUMN appeals.appeals_list.contractor_org
			IS 'Организация исполнителя';
		COMMENT ON COLUMN appeals.appeals_list.contractor_fio
			IS 'ФИО исполнителя';
		COMMENT ON COLUMN appeals.appeals_list.head_org
			IS 'Организация руководителя';
		COMMENT ON COLUMN appeals.appeals_list.head_fio
			IS 'ФИО руководителя';
		COMMENT ON COLUMN appeals.appeals_list.issue_date
			IS 'Дата вынесения';
		COMMENT ON COLUMN appeals.appeals_list.upload_date
			IS 'Дата загрузки';
    </sql>
  </changeSet>

	<changeSet id="0002" author="adel.ka" dbms="postgresql">
		<comment>add primary key</comment>
		<addPrimaryKey
				columnNames="number"
				constraintName="pk_appeals_list"
				tableName="appeals_list"
				schemaName="appeals" />
	</changeSet>

</databaseChangeLog>
