SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

CREATE SCHEMA IF NOT EXISTS public;

ALTER SCHEMA public OWNER TO "ervu-dashboard";

CREATE SCHEMA IF NOT EXISTS appeals;

ALTER SCHEMA appeals OWNER TO "ervu-dashboard";

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

CREATE SCHEMA IF NOT EXISTS ervu_dashboard;

ALTER SCHEMA ervu_dashboard OWNER TO "ervu-dashboard";

CREATE SCHEMA IF NOT EXISTS main_dashboard;

ALTER SCHEMA main_dashboard OWNER TO "ervu-dashboard";

CREATE SCHEMA IF NOT EXISTS ratings;

ALTER SCHEMA ratings OWNER TO "ervu-dashboard";

CREATE SCHEMA IF NOT EXISTS recruitment_campaign;

ALTER SCHEMA recruitment_campaign OWNER TO "ervu-dashboard";

CREATE SCHEMA IF NOT EXISTS space;

ALTER SCHEMA space OWNER TO "ervu-dashboard";

CREATE SCHEMA IF NOT EXISTS total_registered;

ALTER SCHEMA total_registered OWNER TO "ervu-dashboard";

CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA ervu_dashboard;

COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';

CREATE TYPE ervu_dashboard.employer_category_type AS ENUM ('fl', 'ul', 'kfh', 'ip');

ALTER TYPE ervu_dashboard.employer_category_type OWNER TO "ervu-dashboard";

CREATE TYPE ervu_dashboard.type_property_type AS ENUM ('realty', 'ground_transportation', 'air_vehicles', 'water_vehicles');

ALTER TYPE ervu_dashboard.type_property_type OWNER TO "ervu-dashboard";

-- If this function is not required anywhere, remove it
-- CREATE FUNCTION ervu_dashboard.uuid_generate_v4() RETURNS uuid LANGUAGE c STRICT PARALLEL SAFE AS '$libdir/uuid-ossp', 'uuid_generate_v4';
--
-- ALTER FUNCTION ervu_dashboard.uuid_generate_v4() OWNER TO "ervu-dashboard";

SET default_tablespace = '';

SET default_table_access_method = heap;

CREATE TABLE IF NOT EXISTS appeals.main_profile
(
    id_main_profile bigint NOT NULL,
    gender text,
    age text,
    child_min_18 text,
    education text,
    employment text,
    recording_date date DEFAULT now(),
    recruitment_id character(36)
);

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

COMMENT ON TABLE appeals.main_profile IS 'Основной профиль уровень РФ';

COMMENT ON COLUMN appeals.main_profile.gender IS 'Пол';

COMMENT ON COLUMN appeals.main_profile.age IS 'Возраст';

COMMENT ON COLUMN appeals.main_profile.child_min_18 IS 'Дети до 18 лет';

COMMENT ON COLUMN appeals.main_profile.education IS 'Образование';

COMMENT ON COLUMN appeals.main_profile.employment IS 'Занятость';

COMMENT ON COLUMN appeals.main_profile.recording_date IS 'Дата записи';

CREATE SEQUENCE appeals.main_profile_id_main_profile_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;


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

ALTER SEQUENCE appeals.main_profile_id_main_profile_seq OWNED BY appeals.main_profile.id_main_profile;

CREATE TABLE IF NOT EXISTS appeals.reasons_appeal
(
    id_reasons_appeal bigint NOT NULL,
    appeal numeric,
    incorrect_inf numeric,
    no_data numeric,
    other numeric,
    recording_date date DEFAULT now(), -- Исправлено
    incorrect_inf_percent numeric,
    no_data_percent numeric,
    other_percent numeric,
    recruitment_id character(36)
);


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

COMMENT ON TABLE appeals.reasons_appeal IS 'Причины обжалования уровень РФ';

COMMENT ON COLUMN appeals.reasons_appeal.appeal IS 'Обжалования';

COMMENT ON COLUMN appeals.reasons_appeal.incorrect_inf IS 'Некорректные сведения';

COMMENT ON COLUMN appeals.reasons_appeal.no_data IS 'Нет данных';

COMMENT ON COLUMN appeals.reasons_appeal.other IS 'Прочее';

COMMENT ON COLUMN appeals.reasons_appeal.recording_date IS 'Дата записи';

COMMENT ON COLUMN appeals.reasons_appeal.incorrect_inf_percent IS 'Некорректные сведения в процентах';

COMMENT ON COLUMN appeals.reasons_appeal.no_data_percent IS 'Нет данных в процентах';

COMMENT ON COLUMN appeals.reasons_appeal.other_percent IS 'Прочее в процентах';

CREATE SEQUENCE appeals.reasons_appeal_id_reasons_appeal_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE appeals.reasons_appeal_id_reasons_appeal_seq OWNED BY appeals.reasons_appeal.id_reasons_appeal;

CREATE TABLE IF NOT EXISTS appeals.review_rating (
    id_review_rating bigint NOT NULL,
    speed numeric,
    rating numeric,
    recording_date date DEFAULT now(),
    id_region bigint,
    recruitment_id uuid
);

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

COMMENT ON TABLE appeals.review_rating IS 'Рейтинг рассмотрения жалоб уровень РФ';

COMMENT ON COLUMN appeals.review_rating.speed IS 'Скорость рассмотрения';

COMMENT ON COLUMN appeals.review_rating.rating IS 'Оценка удовлетворенности';

COMMENT ON COLUMN appeals.review_rating.recording_date IS 'Дата записи';

CREATE SEQUENCE appeals.review_rating_id_review_rating_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE appeals.review_rating_id_review_rating_seq OWNED BY appeals.review_rating.id_review_rating;

CREATE TABLE IF NOT EXISTS appeals.topic_appeal (
    id_topic_appeal bigint NOT NULL,
    registration numeric,
    sabpoena numeric,
    appear numeric,
    temporary_measures numeric,
    recording_date date DEFAULT now(),
    registration_percent numeric,
    sabpoena_percent numeric,
    appear_percent numeric,
    temporary_measures_percent numeric,
    recruitment_id character(36)
);

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

COMMENT ON TABLE appeals.topic_appeal IS 'Тема обжалования уровень РФ';

COMMENT ON COLUMN appeals.topic_appeal.registration IS 'Тема обжалования постановка на учет';

COMMENT ON COLUMN appeals.topic_appeal.sabpoena IS 'Тема обжалования повестки';

COMMENT ON COLUMN appeals.topic_appeal.appear IS 'Тема обжалования явка';

COMMENT ON COLUMN appeals.topic_appeal.temporary_measures IS 'Тема обжалования временные меры';

COMMENT ON COLUMN appeals.topic_appeal.recording_date IS 'Дата записи';

COMMENT ON COLUMN appeals.topic_appeal.registration_percent IS 'Тема обжалования постановка на учет в процентах';

COMMENT ON COLUMN appeals.topic_appeal.sabpoena_percent IS 'Тема обжалования повестки в процентах';

COMMENT ON COLUMN appeals.topic_appeal.appear_percent IS 'Тема обжалования явка в процентах';

COMMENT ON COLUMN appeals.topic_appeal.temporary_measures_percent IS 'Тема обжалования временные меры в процентах';

CREATE SEQUENCE appeals.topic_appeal_id_topic_appeal_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE appeals.topic_appeal_id_topic_appeal_seq OWNED BY appeals.topic_appeal.id_topic_appeal;

CREATE TABLE IF NOT EXISTS ervu_dashboard.citizen (
    residence character varying,
    is_registered character varying,
    passport_series character varying,
    passport_number character varying,
    phone character varying,
    medical_requirements character varying,
    deferment_liberation character varying,
    gender character varying,
    marital_status character varying,
    education character varying,
    employment character varying,
    reason_registration character varying,
    driver_license character varying,
    disability_group character varying,
    dispensary_registration_code character varying,
    region_birth character varying,
    city_birth character varying,
    right_deferment boolean,
    took_break boolean,
    medic boolean,
    sports_category boolean,
    tractor_license boolean,
    is_wanted boolean,
    is_in_prison boolean,
    acquired_citizenship boolean,
    urgent_service boolean,
    contract_service boolean,
    mobilization boolean,
    full_name character varying,
    last_name character varying,
    first_name character varying,
    middle_name character varying,
    age numeric,
    birth_place character varying,
    number_children numeric,
    birth_date date,
    recruit_id uuid NOT NULL,
    recruitment_id uuid,
    issue_date date,
    number_children_18_old numeric
);

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

COMMENT ON COLUMN ervu_dashboard.citizen.residence IS 'Адрес места жительства';

COMMENT ON COLUMN ervu_dashboard.citizen.is_registered IS 'Сведения о воинском учёте';

COMMENT ON COLUMN ervu_dashboard.citizen.passport_series IS 'Серия паспорта';

COMMENT ON COLUMN ervu_dashboard.citizen.passport_number IS 'Номер паспорта';

COMMENT ON COLUMN ervu_dashboard.citizen.phone IS 'Телефон';

COMMENT ON COLUMN ervu_dashboard.citizen.medical_requirements IS 'Медицинские сведения';

COMMENT ON COLUMN ervu_dashboard.citizen.deferment_liberation IS 'Наличие отсрочки или освобождения от военной службы';

COMMENT ON COLUMN ervu_dashboard.citizen.gender IS 'Пол';

COMMENT ON COLUMN ervu_dashboard.citizen.marital_status IS 'Семейное положение';

COMMENT ON COLUMN ervu_dashboard.citizen.education IS 'Образование';

COMMENT ON COLUMN ervu_dashboard.citizen.employment IS 'Занятость';

COMMENT ON COLUMN ervu_dashboard.citizen.reason_registration IS 'Причина постановки на учёт';

COMMENT ON COLUMN ervu_dashboard.citizen.driver_license IS 'Водительское удостоверение';

COMMENT ON COLUMN ervu_dashboard.citizen.disability_group IS 'Группа инвалидности';

COMMENT ON COLUMN ervu_dashboard.citizen.dispensary_registration_code IS 'Код диспансерного учета';

COMMENT ON COLUMN ervu_dashboard.citizen.region_birth IS 'Регион места рождения';

COMMENT ON COLUMN ervu_dashboard.citizen.city_birth IS 'Город места рождения';

COMMENT ON COLUMN ervu_dashboard.citizen.right_deferment IS 'Имеет право на отсрочку';

COMMENT ON COLUMN ervu_dashboard.citizen.took_break IS 'Воспользовался отсрочкой';

COMMENT ON COLUMN ervu_dashboard.citizen.medic IS 'Является медиком';

COMMENT ON COLUMN ervu_dashboard.citizen.sports_category IS 'Имеет спортивный разряд/звание';

COMMENT ON COLUMN ervu_dashboard.citizen.tractor_license IS 'Имеет удостоверение тракториста';

COMMENT ON COLUMN ervu_dashboard.citizen.is_wanted IS 'Находится в розыске';

COMMENT ON COLUMN ervu_dashboard.citizen.is_in_prison IS 'Находится в местах лишения свободы';

COMMENT ON COLUMN ervu_dashboard.citizen.acquired_citizenship IS 'Получивший гражданство';

COMMENT ON COLUMN ervu_dashboard.citizen.urgent_service IS 'Признак критерия срочной службы';

COMMENT ON COLUMN ervu_dashboard.citizen.contract_service IS 'Признак критерия контрактной службы';

COMMENT ON COLUMN ervu_dashboard.citizen.mobilization IS 'Признак критерия службы по мобмлизации';

COMMENT ON COLUMN ervu_dashboard.citizen.recruit_id IS 'id рекрута из БД ЕРВУ';

CREATE TABLE IF NOT EXISTS ervu_dashboard.citizen_child (
    citizen_child_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    kinship_type character varying(50),
    full_name character varying,
    birth_date date,
    birth_az_number character varying(50),
    death_date date,
    death_az_number character varying(50)
);

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

COMMENT ON TABLE ervu_dashboard.citizen_child IS 'сведения о детях гражданина';

COMMENT ON COLUMN ervu_dashboard.citizen_child.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.citizen_child.kinship_type IS 'тип родственной связи: сын/дочь';

COMMENT ON COLUMN ervu_dashboard.citizen_child.full_name IS 'ФИО';

COMMENT ON COLUMN ervu_dashboard.citizen_child.birth_az_number IS 'номер актовой записи о рождении';

COMMENT ON COLUMN ervu_dashboard.citizen_child.death_az_number IS 'номер актовой записи о смерти';

CREATE SEQUENCE ervu_dashboard.citizen_child_citizen_child_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.citizen_child_citizen_child_id_seq OWNED BY ervu_dashboard.citizen_child.citizen_child_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.citizen_guardianship (
    citizen_guardianship_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    full_name character varying,
    birth_date date,
    snils character varying(50)
);

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

COMMENT ON TABLE ervu_dashboard.citizen_guardianship IS 'сведения о лице, опекаемом или находящемся на попечении';

COMMENT ON COLUMN ervu_dashboard.citizen_guardianship.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.citizen_guardianship.full_name IS 'ФИО';

CREATE SEQUENCE ervu_dashboard.citizen_guardianship_citizen_guardianship_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.citizen_guardianship_citizen_guardianship_id_seq OWNED BY ervu_dashboard.citizen_guardianship.citizen_guardianship_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.citizen_spouse (
    citizen_spouse_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    kinship_type character varying(50),
    full_name character varying,
    birth_date date,
    death_az_number character varying(50),
    death_date date,
    marriage_az_number character varying(50),
    marriage_date date,
    divorce_az_number character varying(50),
    divorce_date date,
    information_excluded boolean DEFAULT false
);

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

COMMENT ON TABLE ervu_dashboard.citizen_spouse IS 'сведения о супруге (бывшей/ем супруге) гражданина';

COMMENT ON COLUMN ervu_dashboard.citizen_spouse.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.citizen_spouse.kinship_type IS 'тип родственной связи: супруг/бывший супруг';

COMMENT ON COLUMN ervu_dashboard.citizen_spouse.full_name IS 'ФИО';

COMMENT ON COLUMN ervu_dashboard.citizen_spouse.death_az_number IS 'номер актовой записи о смерти';

COMMENT ON COLUMN ervu_dashboard.citizen_spouse.marriage_az_number IS 'номер актовой записи о браке';

COMMENT ON COLUMN ervu_dashboard.citizen_spouse.divorce_az_number IS 'номер актовой записи о расторжении брака';

COMMENT ON COLUMN ervu_dashboard.citizen_spouse.information_excluded IS 'сведения о супруге исключены';

CREATE SEQUENCE ervu_dashboard.citizen_spouse_citizen_spouse_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.citizen_spouse_citizen_spouse_id_seq OWNED BY ervu_dashboard.citizen_spouse.citizen_spouse_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.citizenship (
    citizenship_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    acquiring_basis text,
    acquiring_number character varying(20),
    acquiring_date date,
    acquiring_authority text,
    renunciation_basis text,
    renunciation_number character varying(20),
    renunciation_date date,
    renunciation_authority text
);

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

COMMENT ON TABLE ervu_dashboard.citizenship IS 'сведения о гражданстве РФ';

COMMENT ON COLUMN ervu_dashboard.citizenship.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.citizenship.acquiring_basis IS 'основание приобретения гражданства РФ';

COMMENT ON COLUMN ervu_dashboard.citizenship.acquiring_number IS 'номер решения о приобретении гражданства РФ';

COMMENT ON COLUMN ervu_dashboard.citizenship.acquiring_date IS 'дата решения о приобретении гражданства РФ';

COMMENT ON COLUMN ervu_dashboard.citizenship.acquiring_authority IS 'наименование органа, принявшего решение о приобретении гражданства РФ';

COMMENT ON COLUMN ervu_dashboard.citizenship.renunciation_basis IS 'основание выхода гражданства РФ';

COMMENT ON COLUMN ervu_dashboard.citizenship.renunciation_number IS 'номер решения о выходе из гражданства РФ';

COMMENT ON COLUMN ervu_dashboard.citizenship.renunciation_date IS 'дата решения о выходе из гражданства РФ';

COMMENT ON COLUMN ervu_dashboard.citizenship.renunciation_authority IS 'наименование органа, принявшего решение о выходе из гражданства РФ';

CREATE SEQUENCE ervu_dashboard.citizenship_citizenship_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.citizenship_citizenship_id_seq OWNED BY ervu_dashboard.citizenship.citizenship_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.citizenship_foreign (
    citizenship_foreign_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    country_name character varying(255),
    residense_right_basis character varying(255),
    residense_right_date date,
    citizenship_basis character varying(255),
    citizenship_date date
);

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

COMMENT ON TABLE ervu_dashboard.citizenship_foreign IS 'сведения об иностранном гражданстве';

COMMENT ON COLUMN ervu_dashboard.citizenship_foreign.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.citizenship_foreign.country_name IS 'наименование государства';

COMMENT ON COLUMN ervu_dashboard.citizenship_foreign.residense_right_basis IS 'основание получения права на постоянное проживание';

COMMENT ON COLUMN ervu_dashboard.citizenship_foreign.residense_right_date IS 'дата возникновения права на постоянное проживание';

COMMENT ON COLUMN ervu_dashboard.citizenship_foreign.citizenship_basis IS 'основание получения иностранного гражданства';

COMMENT ON COLUMN ervu_dashboard.citizenship_foreign.citizenship_date IS 'дата получения иностранного гражданства';

CREATE SEQUENCE ervu_dashboard.citizenship_foreign_citizenship_foreign_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.citizenship_foreign_citizenship_foreign_id_seq OWNED BY ervu_dashboard.citizenship_foreign.citizenship_foreign_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.decision (
    decision_id bigint NOT NULL,
    subpoena_id uuid,
    recruit_id uuid,
    recruitment_id uuid
);

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

CREATE SEQUENCE ervu_dashboard.decision_decision_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.decision_decision_id_seq OWNED BY ervu_dashboard.decision.decision_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.deputy (
    deputy_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    deputy boolean DEFAULT true,
    information text,
    end_date date,
    period_office character varying(50),
    cancellation_date date
);

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

COMMENT ON TABLE ervu_dashboard.deputy IS 'сведения о гражданах, избранных депутатами/зарегистрированных кандидатами на участие в выборах';

COMMENT ON COLUMN ervu_dashboard.deputy.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.deputy.deputy IS 'является депутатом(true)/кандидатом на участие в выборах(false)';

COMMENT ON COLUMN ervu_dashboard.deputy.information IS 'сведения об избрании гражданина депутатом/сведения о регистрации кандидатом на выборах';

COMMENT ON COLUMN ervu_dashboard.deputy.end_date IS 'дата досрочного прекращения полномочий/снятия кандидатуры с выборов';

COMMENT ON COLUMN ervu_dashboard.deputy.period_office IS 'срок полномочий';

COMMENT ON COLUMN ervu_dashboard.deputy.cancellation_date IS 'дата аннулирования регистрации';

CREATE SEQUENCE ervu_dashboard.deputy_deputy_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.deputy_deputy_id_seq OWNED BY ervu_dashboard.deputy.deputy_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.disability (
    disability_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    disability boolean DEFAULT false,
    organization_name character varying(300),
    start_date date,
    close_date date,
    confirmation_date date,
    re_examination_date date,
    disability_group character varying(30)
);

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

COMMENT ON TABLE ervu_dashboard.disability IS 'сведения об инвалидности/недееспособности/ограниченной дееспособности';

COMMENT ON COLUMN ervu_dashboard.disability.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.disability.disability IS 'сведения об инвалидности(true)/недееспособности(false)';

COMMENT ON COLUMN ervu_dashboard.disability.organization_name IS 'наименование организации, установившей инвалидность/судебного органа';

COMMENT ON COLUMN ervu_dashboard.disability.start_date IS 'дата установления инвалидности/признания гражданина недееспособным';

COMMENT ON COLUMN ervu_dashboard.disability.close_date IS 'дата снятия инвалидности/отмены ограничения гражданина в дееспособности';

COMMENT ON COLUMN ervu_dashboard.disability.confirmation_date IS 'дата подтверждения инвалидности';

COMMENT ON COLUMN ervu_dashboard.disability.re_examination_date IS 'дата переосвидетельствования по инвалидности';

COMMENT ON COLUMN ervu_dashboard.disability.disability_group IS 'группа инвалидности';

CREATE SEQUENCE ervu_dashboard.disability_disability_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.disability_disability_id_seq OWNED BY ervu_dashboard.disability.disability_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.disease (
    disease_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    code character varying,
    name character varying,
    reg_date date,
    registered boolean DEFAULT false
);

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

COMMENT ON TABLE ervu_dashboard.disease IS 'сведения о заболеваниях гражданина';

COMMENT ON COLUMN ervu_dashboard.disease.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.disease.code IS 'код заболевания';

COMMENT ON COLUMN ervu_dashboard.disease.name IS 'наименование заболевания';

COMMENT ON COLUMN ervu_dashboard.disease.reg_date IS 'дата постановки диагноза';

COMMENT ON COLUMN ervu_dashboard.disease.registered IS 'поставлен на учет по заболеванию';

CREATE SEQUENCE ervu_dashboard.disease_disease_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.disease_disease_id_seq OWNED BY ervu_dashboard.disease.disease_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.drivers_licence (
    drivers_licence_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    tractor_driver boolean DEFAULT false,
    licence_series character varying(50),
    licence_number character varying(50),
    start_date date,
    close_date date,
    categories character varying(50),
    status character varying(50),
    replacement_date date,
    return_date date,
    seizure_date date
);

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

COMMENT ON TABLE ervu_dashboard.drivers_licence IS 'удостоверение водительское/тракториста-машиниста';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.tractor_driver IS 'удостоверение тракториста';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.licence_series IS 'серия';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.licence_number IS 'номер';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.start_date IS 'дата выдачи';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.close_date IS 'дата окончания действия';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.categories IS 'категории';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.status IS 'статус удостоверения';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.replacement_date IS 'дата замены';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.return_date IS 'дата возврата';

COMMENT ON COLUMN ervu_dashboard.drivers_licence.seizure_date IS 'дата изъятия';

CREATE SEQUENCE ervu_dashboard.drivers_licence_drivers_licence_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.drivers_licence_drivers_licence_id_seq OWNED BY ervu_dashboard.drivers_licence.drivers_licence_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.medical_authorities (
    medical_authorities_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    start_date date,
    close_date date,
    change_date date,
    hiv boolean DEFAULT false
);

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

COMMENT ON TABLE ervu_dashboard.medical_authorities IS 'сведения о гражданах, стоящих на учете в ПНД/по ВИЧ';

COMMENT ON COLUMN ervu_dashboard.medical_authorities.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.medical_authorities.start_date IS 'дата постановки на учет';

COMMENT ON COLUMN ervu_dashboard.medical_authorities.close_date IS 'дата снятия с учета';

COMMENT ON COLUMN ervu_dashboard.medical_authorities.change_date IS 'дата планового срока пересмотра диагноза';

COMMENT ON COLUMN ervu_dashboard.medical_authorities.hiv IS 'на учете по ВИЧ(true) или в ПНД(false)';

CREATE SEQUENCE ervu_dashboard.medical_authorities_medical_authorities_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.medical_authorities_medical_authorities_id_seq OWNED BY ervu_dashboard.medical_authorities.medical_authorities_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.passport (
    passport_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    actual boolean DEFAULT true,
    passport_series character varying(4),
    passport_number character varying(6),
    issue_date date,
    organization_name character varying(255),
    unit_code character varying(7)
);

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

COMMENT ON TABLE ervu_dashboard.passport IS 'сведения о паспорте';

COMMENT ON COLUMN ervu_dashboard.passport.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.passport.actual IS 'статус документа: действительный(true)/недействительный(false)';

COMMENT ON COLUMN ervu_dashboard.passport.passport_series IS 'серия паспорта';

COMMENT ON COLUMN ervu_dashboard.passport.passport_number IS 'номер паспорта';

COMMENT ON COLUMN ervu_dashboard.passport.issue_date IS 'дата выдачи документа';

COMMENT ON COLUMN ervu_dashboard.passport.organization_name IS 'наименование органа, выдавшего документ';

COMMENT ON COLUMN ervu_dashboard.passport.unit_code IS 'код подразделения';

CREATE SEQUENCE ervu_dashboard.passport_passport_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.passport_passport_id_seq OWNED BY ervu_dashboard.passport.passport_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.property (
    property_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    type_property ervu_dashboard.type_property_type,
    start_date date,
    close_date date,
    vehicle_type character varying(100),
    vehicle_category character varying(100),
    address text,
    kind_right character varying(50),
    issue_year character varying(4),
    brand_model character varying(100),
    reg_plate character varying(100),
    vin character varying(100)
);

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

COMMENT ON TABLE ervu_dashboard.property IS 'сведения об имуществе';

COMMENT ON COLUMN ervu_dashboard.property.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.property.type_property IS 'тип имущества: недвижимое/наземный/воздушный/водный транспорт';

COMMENT ON COLUMN ervu_dashboard.property.start_date IS 'дата регистрации права владения';

COMMENT ON COLUMN ervu_dashboard.property.close_date IS 'дата прекращения права владения';

COMMENT ON COLUMN ervu_dashboard.property.vehicle_type IS 'вид транспортного средства';

COMMENT ON COLUMN ervu_dashboard.property.vehicle_category IS 'категория транспортного средства';

COMMENT ON COLUMN ervu_dashboard.property.address IS 'адрес объекта недвижимости';

COMMENT ON COLUMN ervu_dashboard.property.kind_right IS 'вид права';

COMMENT ON COLUMN ervu_dashboard.property.issue_year IS 'год выпуска транспортного средства';

COMMENT ON COLUMN ervu_dashboard.property.brand_model IS 'марка, модель транспортного средства';

COMMENT ON COLUMN ervu_dashboard.property.reg_plate IS 'регистрационный номер';

CREATE SEQUENCE ervu_dashboard.property_property_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.property_property_id_seq OWNED BY ervu_dashboard.property.property_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.prosecution (
    prosecution_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    kind character varying(255),
    create_date date,
    close_date date,
    authority_name character varying(255),
    law_point character varying(100),
    termination_basis character varying(255),
    transfer_to_court boolean DEFAULT false,
    case_number character varying(50),
    case_number_court character varying(50),
    reclassification text
);

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

COMMENT ON TABLE ervu_dashboard.prosecution IS 'сведения об уголовном преследовании';

COMMENT ON COLUMN ervu_dashboard.prosecution.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.prosecution.kind IS 'вид уголовного преследования';

COMMENT ON COLUMN ervu_dashboard.prosecution.create_date IS 'дата возбуждения уголовного дела';

COMMENT ON COLUMN ervu_dashboard.prosecution.close_date IS 'дата прекращения уголовного преследования';

COMMENT ON COLUMN ervu_dashboard.prosecution.authority_name IS 'наименование органа, принявшего решение';

COMMENT ON COLUMN ervu_dashboard.prosecution.law_point IS 'пункт, часть, статья УК РФ';

COMMENT ON COLUMN ervu_dashboard.prosecution.termination_basis IS 'основание прекращения уголовного преследования';

COMMENT ON COLUMN ervu_dashboard.prosecution.transfer_to_court IS 'признак передачи в суд уголовного дела в отношении гражданина';

COMMENT ON COLUMN ervu_dashboard.prosecution.case_number IS 'номер уголовного дела (предварительный)';

COMMENT ON COLUMN ervu_dashboard.prosecution.case_number_court IS 'номер уголовного дела (судебный)';

COMMENT ON COLUMN ervu_dashboard.prosecution.reclassification IS 'сведения о переквалификации деяния';

CREATE SEQUENCE ervu_dashboard.prosecution_prosecution_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.prosecution_prosecution_id_seq OWNED BY ervu_dashboard.prosecution.prosecution_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.pub_recruitment (
    idm_id character varying(256),
    parent_id character varying,
    military_code character varying,
    shortname character varying NOT NULL,
    fullname character varying NOT NULL,
    code character varying(64),
    id character(36) NOT NULL,
    sort character varying NOT NULL
);

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

CREATE TABLE IF NOT EXISTS ervu_dashboard.punishment (
    punishment_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    sentence character varying(255),
    sentence_changed character varying(255),
    sentense_date date,
    authority_name character varying(255),
    law_point character varying(100),
    punishment_type character varying(100),
    punishment_code character varying(5),
    sentence_place text,
    start_date date,
    planned_date date,
    release_date date,
    release_reason character varying(255),
    mandatory_work boolean DEFAULT false
);

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

COMMENT ON TABLE ervu_dashboard.punishment IS 'сведения об уголовном преследовании и вынесенном приговоре';

COMMENT ON COLUMN ervu_dashboard.punishment.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.punishment.sentence IS 'срок или размер наказания';

COMMENT ON COLUMN ervu_dashboard.punishment.sentence_changed IS 'изменение срока или размера наказания';

COMMENT ON COLUMN ervu_dashboard.punishment.sentense_date IS 'дата вынесения обвинительного приговора';

COMMENT ON COLUMN ervu_dashboard.punishment.authority_name IS 'наименование суда, вынесшего приговор';

COMMENT ON COLUMN ervu_dashboard.punishment.law_point IS 'пункт, часть, статья УК РФ';

COMMENT ON COLUMN ervu_dashboard.punishment.punishment_type IS 'вид наказания';

COMMENT ON COLUMN ervu_dashboard.punishment.punishment_code IS 'код вида наказания';

COMMENT ON COLUMN ervu_dashboard.punishment.sentence_place IS 'наименование и адрес места отбывания наказания';

COMMENT ON COLUMN ervu_dashboard.punishment.start_date IS 'дата начала срока отбывания наказания';

COMMENT ON COLUMN ervu_dashboard.punishment.planned_date IS 'плановая дата отбытия';

COMMENT ON COLUMN ervu_dashboard.punishment.release_date IS 'дата освобождения';

COMMENT ON COLUMN ervu_dashboard.punishment.release_reason IS 'основание освобождения';

COMMENT ON COLUMN ervu_dashboard.punishment.mandatory_work IS 'признак отбывания наказания в виде обязательных работ';

CREATE SEQUENCE ervu_dashboard.punishment_punishment_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.punishment_punishment_id_seq OWNED BY ervu_dashboard.punishment.punishment_id;

CREATE TABLE IF NOT EXISTS ervu_dashboard.recruitment (
    id character(36) NOT NULL,
    shortname character(300),
    idm_id uuid,
    code character(300),
    parent_id character(300),
    sort bigint NOT NULL
);

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

CREATE TABLE IF NOT EXISTS ervu_dashboard.subpoena (
    sub_id bigint NOT NULL,
    series character varying(16),
    number character varying(36) NOT NULL,
    create_date timestamp without time zone DEFAULT now() NOT NULL,
    visit_date timestamp without time zone,
    send_date timestamp with time zone,
    reason_cancelled character varying(255),
    recruit_id uuid,
    department_id uuid,
    subpoena_status text,
    subpoena_reason text,
    fio_commiss text,
    track_number text,
    recruitment_name text,
    address text,
    method_sending text,
    subpoena_id uuid,
    sig_info character varying(255),
    delivery_fio text,
    act_number text,
    method_delivery text,
    delivery_date timestamp without time zone,
    delivery_status text,
    appearance text,
    appearance_status text
);

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

COMMENT ON TABLE ervu_dashboard.subpoena IS 'сведения о направлении повестки военного комиссариата';

COMMENT ON COLUMN ervu_dashboard.subpoena.series IS 'серия повестки';

COMMENT ON COLUMN ervu_dashboard.subpoena.number IS 'номер повестки';

COMMENT ON COLUMN ervu_dashboard.subpoena.create_date IS 'дата создания записи';

COMMENT ON COLUMN ervu_dashboard.subpoena.visit_date IS 'время и дата явки в ВК';

COMMENT ON COLUMN ervu_dashboard.subpoena.send_date IS 'дата направления повестки';

COMMENT ON COLUMN ervu_dashboard.subpoena.reason_cancelled IS 'причина отклонения повестки';

COMMENT ON COLUMN ervu_dashboard.subpoena.recruit_id IS 'идентификатор рекрута';

COMMENT ON COLUMN ervu_dashboard.subpoena.department_id IS 'идентификатор ВК';

COMMENT ON COLUMN ervu_dashboard.subpoena.subpoena_status IS 'статус повестки';

COMMENT ON COLUMN ervu_dashboard.subpoena.subpoena_reason IS 'причина вызова по повестке';

COMMENT ON COLUMN ervu_dashboard.subpoena.fio_commiss IS 'фио комиссара';

COMMENT ON COLUMN ervu_dashboard.subpoena.track_number IS 'уникальный номер заказного почтового отправления, которым направлена повестка';

COMMENT ON COLUMN ervu_dashboard.subpoena.recruitment_name IS 'наименование ВК, направившего повестку';

COMMENT ON COLUMN ervu_dashboard.subpoena.address IS 'адрес, по которому нужно явиться по повестке';

COMMENT ON COLUMN ervu_dashboard.subpoena.method_sending IS 'способ направления повестки';

COMMENT ON COLUMN ervu_dashboard.subpoena.subpoena_id IS 'идентификатор повестки';

COMMENT ON COLUMN ervu_dashboard.subpoena.sig_info IS 'открепленная ЭП';

COMMENT ON COLUMN ervu_dashboard.subpoena.delivery_fio IS 'фио лица, оповестившего гражданина о последствиях отказа от получения повестки';

COMMENT ON COLUMN ervu_dashboard.subpoena.act_number IS 'номер акта об отказе от получения повестки';

COMMENT ON COLUMN ervu_dashboard.subpoena.method_delivery IS 'способ вручения';

ALTER TABLE IF EXISTS ervu_dashboard.subpoena ALTER COLUMN sub_id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME ervu_dashboard.subpoena_subpoena_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
    );

CREATE TABLE IF NOT EXISTS ervu_dashboard.temporary_measures (
    temporary_measures_id bigint NOT NULL,
    subpoena_id uuid,
    recruit_id uuid,
    recruitment_id uuid,
    status_measure text,
    recruitment_name text,
    cancel_date timestamp without time zone,
    restriction_name text,
    type text,
    decision_number_create text,
    decision_number_cancel text,
    decision_date_create timestamp without time zone,
    decision_date_cancel timestamp without time zone,
    applied_fact text
);

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

COMMENT ON COLUMN ervu_dashboard.temporary_measures.status_measure IS 'статус временной меры';

COMMENT ON COLUMN ervu_dashboard.temporary_measures.recruitment_name IS 'наименование ВК';

COMMENT ON COLUMN ervu_dashboard.temporary_measures.cancel_date IS 'дата, с которой отменена временная мера';

COMMENT ON COLUMN ervu_dashboard.temporary_measures.restriction_name IS 'наименование временной меры';

COMMENT ON COLUMN ervu_dashboard.temporary_measures.type IS 'тип документа ограничения';

COMMENT ON COLUMN ervu_dashboard.temporary_measures.decision_number_create IS 'номер решения о применении временной меры';

COMMENT ON COLUMN ervu_dashboard.temporary_measures.decision_number_cancel IS 'номер решения об отмене временной меры';

COMMENT ON COLUMN ervu_dashboard.temporary_measures.decision_date_create IS 'дата решения о применении временной меры';

COMMENT ON COLUMN ervu_dashboard.temporary_measures.decision_date_cancel IS 'дата решения об отмене временной меры';

COMMENT ON COLUMN ervu_dashboard.temporary_measures.applied_fact IS 'факт применения временной меры';

ALTER TABLE IF EXISTS ervu_dashboard.temporary_measures ALTER COLUMN temporary_measures_id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME ervu_dashboard.temporary_measures_temporary_measures_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
    );

ALTER TABLE IF EXISTS ervu_dashboard.recruitment ALTER COLUMN sort ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME ervu_dashboard.testrecruitment_sort_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
    );

CREATE TABLE IF NOT EXISTS ervu_dashboard.work (
    work_id bigint NOT NULL,
    recruit_id uuid NOT NULL,
    employer_category ervu_dashboard.employer_category_type,
    place text,
    organization_name character varying(100),
    inn character varying(15),
    kpp character varying(15),
    ogrnip character varying(20),
    "position" character varying(150),
    event_type character varying(50),
    event_date date
);

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

COMMENT ON TABLE ervu_dashboard.work IS 'сведения об имуществе';

COMMENT ON COLUMN ervu_dashboard.work.recruit_id IS 'ссылка на гражданина (citizen)';

COMMENT ON COLUMN ervu_dashboard.work.employer_category IS 'категория работодателя: юр лицо/ИП/физ лицо/глава КФХ';

COMMENT ON COLUMN ervu_dashboard.work.place IS 'место работы';

COMMENT ON COLUMN ervu_dashboard.work.organization_name IS 'наименование организации';

COMMENT ON COLUMN ervu_dashboard.work.inn IS 'ИНН';

COMMENT ON COLUMN ervu_dashboard.work.kpp IS 'КПП';

COMMENT ON COLUMN ervu_dashboard.work.ogrnip IS 'ОГРНИП';

COMMENT ON COLUMN ervu_dashboard.work."position" IS 'должность';

COMMENT ON COLUMN ervu_dashboard.work.event_type IS 'тип кадрового мероприятия ';

COMMENT ON COLUMN ervu_dashboard.work.event_date IS 'дата кадрового мероприятия';

CREATE SEQUENCE ervu_dashboard.work_work_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

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

ALTER SEQUENCE ervu_dashboard.work_work_id_seq OWNED BY ervu_dashboard.work.work_id;

CREATE TABLE IF NOT EXISTS main_dashboard.appeals (
    total_appeals numeric,
    resolved numeric,
    average_consideration numeric,
    average_rating numeric,
    average_to_face numeric,
    "average_EPGU" numeric,
    recording_date date DEFAULT now() NOT NULL,
    average_to_face_percent numeric,
    "average_EPGU_percent" numeric,
    recruitment_id character(36) NOT NULL,
    id_appeal bigint NOT NULL
);

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

COMMENT ON TABLE main_dashboard.appeals IS 'Обжалования уровень РФ';

COMMENT ON COLUMN main_dashboard.appeals.total_appeals IS 'Всего жалоб';

COMMENT ON COLUMN main_dashboard.appeals.resolved IS 'Количество решенных';

COMMENT ON COLUMN main_dashboard.appeals.average_consideration IS 'Средний срок рассмотрения';

COMMENT ON COLUMN main_dashboard.appeals.average_rating IS 'Оценка удовлетворенности';

COMMENT ON COLUMN main_dashboard.appeals.average_to_face IS 'Способ подачи жалоб очно';

COMMENT ON COLUMN main_dashboard.appeals."average_EPGU" IS 'Способ подачи ЕПГУ';

COMMENT ON COLUMN main_dashboard.appeals.recording_date IS 'Дата записи';

COMMENT ON COLUMN main_dashboard.appeals.average_to_face_percent IS 'Способ подачи жалоб очно в процентах';

COMMENT ON COLUMN main_dashboard.appeals."average_EPGU_percent" IS 'Способ подачи ЕПГУ в процентах';

CREATE SEQUENCE main_dashboard.appeals_id_appeal_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS main_dashboard.appeals_id_appeal_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE main_dashboard.appeals_id_appeal_seq OWNED BY main_dashboard.appeals.id_appeal;

CREATE TABLE IF NOT EXISTS main_dashboard.recruitment_campaign (
    new_recruits numeric,
    subpoenas_sent numeric,
    appeared_on_subpoenas numeric,
    not_appeared_on_subpoenas numeric,
    postponement_have_right numeric,
    postponement_granted numeric,
    recording_date date DEFAULT now() NOT NULL,
    appeared_on_subpoenas_percent numeric,
    not_appeared_on_subpoenas_percent numeric,
    postponement_have_right_percent numeric,
    postponement_granted_percent numeric,
    recruitment_id character(36) NOT NULL,
    spring_autumn character(36) NOT NULL,
    id_recruitment_campaign bigint NOT NULL
);

ALTER TABLE IF EXISTS main_dashboard.recruitment_campaign OWNER TO "ervu-dashboard";

COMMENT ON TABLE main_dashboard.recruitment_campaign IS 'Призывная кампания уровень РФ';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.new_recruits IS 'Подпадающие под призыв';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.subpoenas_sent IS 'Направлено повесток';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.appeared_on_subpoenas IS 'Явились по повесткам';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.not_appeared_on_subpoenas IS 'Не явились по повесткам';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.postponement_have_right IS 'Имеют право на отсрочку';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.postponement_granted IS 'Предоставлена отсрочка';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.recording_date IS 'Дата записи';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.appeared_on_subpoenas_percent IS 'Явились по повесткам процент';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.not_appeared_on_subpoenas_percent IS 'Не явились по повесткам процент';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.postponement_have_right_percent IS 'Имеют право на отсрочку процент';

COMMENT ON COLUMN main_dashboard.recruitment_campaign.postponement_granted_percent IS 'Предоставлена отсрочка процент';

CREATE SEQUENCE main_dashboard.recruitment_campaign_id_recruitment_campaign_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS main_dashboard.recruitment_campaign_id_recruitment_campaign_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE main_dashboard.recruitment_campaign_id_recruitment_campaign_seq OWNED BY main_dashboard.recruitment_campaign.id_recruitment_campaign;

CREATE TABLE IF NOT EXISTS main_dashboard.total_registered (
    total_registered numeric,
    "total_registered_M" numeric,
    "total_registered_W" numeric,
    mobilization_criterion numeric,
    volunteer_criterion numeric,
    contract_criterion numeric,
    recording_date date DEFAULT now() NOT NULL,
    mobilization_criterion_percent numeric,
    volunteer_criterion_percent numeric,
    contract_criterion_percent numeric,
    recruitment_id character(36) NOT NULL,
    id_total_registered bigint NOT NULL
);

ALTER TABLE IF EXISTS main_dashboard.total_registered OWNER TO "ervu-dashboard";

COMMENT ON TABLE main_dashboard.total_registered IS 'Всего на учете уровень РФ';

COMMENT ON COLUMN main_dashboard.total_registered.total_registered IS 'Всего состоят на учете';

COMMENT ON COLUMN main_dashboard.total_registered."total_registered_M" IS 'Всего на учете мужчин';

COMMENT ON COLUMN main_dashboard.total_registered."total_registered_W" IS 'Всего на учете женщин';

COMMENT ON COLUMN main_dashboard.total_registered.mobilization_criterion IS 'Количество подходящих под критерии мобилизации';

COMMENT ON COLUMN main_dashboard.total_registered.volunteer_criterion IS 'Количество подходящих под критерии добровольной службы';

COMMENT ON COLUMN main_dashboard.total_registered.contract_criterion IS 'Количество подходящих под критерии контрактной службы';

COMMENT ON COLUMN main_dashboard.total_registered.recording_date IS 'дата записи';

COMMENT ON COLUMN main_dashboard.total_registered.mobilization_criterion_percent IS 'Процент подходящих под критерии мобилизации';

COMMENT ON COLUMN main_dashboard.total_registered.volunteer_criterion_percent IS 'Процент подходящих под критерии добровольной службы';

COMMENT ON COLUMN main_dashboard.total_registered.contract_criterion_percent IS 'Процент подходящих под критерии контрактрой службы';

CREATE SEQUENCE main_dashboard.total_registered_id_total_registered_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS main_dashboard.total_registered_id_total_registered_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE main_dashboard.total_registered_id_total_registered_seq OWNED BY main_dashboard.total_registered.id_total_registered;

CREATE TABLE IF NOT EXISTS main_dashboard.waiting_registration (
    waiting_registration numeric,
    "waiting_registration_M" numeric,
    "waiting_registration_W" numeric,
    mobilization_criterion numeric,
    volunteer_criterion numeric,
    contract_criterion numeric,
    recording_date date DEFAULT now() NOT NULL,
    waiting_registration_percent numeric,
    mobilization_criterion_percent numeric,
    volunteer_criterion_percent numeric,
    contract_criterion_percent numeric,
    recruitment_id character(36) NOT NULL,
    id_waiting_registration bigint NOT NULL
);

ALTER TABLE IF EXISTS main_dashboard.waiting_registration OWNER TO "ervu-dashboard";

COMMENT ON TABLE main_dashboard.waiting_registration IS 'Подлежат постановке на учет уровень РФ';

COMMENT ON COLUMN main_dashboard.waiting_registration.waiting_registration IS 'Всего подлежат постановке на учет';

COMMENT ON COLUMN main_dashboard.waiting_registration."waiting_registration_M" IS 'Подлежат постановке мужчины';

COMMENT ON COLUMN main_dashboard.waiting_registration."waiting_registration_W" IS 'Подлежат постановке женщины';

COMMENT ON COLUMN main_dashboard.waiting_registration.mobilization_criterion IS 'Количество подлежащих под критерии мобилизации';

COMMENT ON COLUMN main_dashboard.waiting_registration.volunteer_criterion IS 'Количество подлежащих под критерии добровольной службы';

COMMENT ON COLUMN main_dashboard.waiting_registration.contract_criterion IS 'Количество подлежащих под критерии контрактной службы';

COMMENT ON COLUMN main_dashboard.waiting_registration.recording_date IS 'Дата записи';

COMMENT ON COLUMN main_dashboard.waiting_registration.waiting_registration_percent IS 'Всего подлежат постановке процент';

COMMENT ON COLUMN main_dashboard.waiting_registration.mobilization_criterion_percent IS 'Процент подлежащих под критерии мобилизации';

COMMENT ON COLUMN main_dashboard.waiting_registration.volunteer_criterion_percent IS 'Процент подлежащих под критерии добровольной службы';

COMMENT ON COLUMN main_dashboard.waiting_registration.contract_criterion_percent IS 'Процент подлежащих под критерии контрактной службы';

CREATE SEQUENCE main_dashboard.waiting_registration_id_waiting_registration_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS main_dashboard.waiting_registration_id_waiting_registration_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE main_dashboard.waiting_registration_id_waiting_registration_seq OWNED BY main_dashboard.waiting_registration.id_waiting_registration;

CREATE TABLE IF NOT EXISTS public.channel_log (
    id_batch bigint,
    channel_id character(36),
    log_date date,
    logging_object_type character varying,
    object_name character varying,
    object_copy character varying,
    repository_directory character varying,
    filename character varying,
    object_id character(36),
    object_version character varying,
    object_revision character varying,
    parent_channel_id character(36),
    root_channel_id character(36)
);

CREATE TABLE IF NOT EXISTS public.job_entry_log (
    id_batch bigint,
    channel_id character(36),
    log_date date,
    transname character varying,
    stepname character varying,
    lines_read character varying,
    lines_written character varying,
    lines_updated character varying,
    lines_input character varying,
    lines_output character varying,
    lines_rejected character varying,
    errors character varying,
    "RESULT" character varying,
    nr_result_rows character varying,
    nr_result_files character varying
);

ALTER TABLE IF EXISTS public.job_entry_log OWNER TO "ervu-dashboard";

CREATE TABLE IF NOT EXISTS public.job_log (
    jobname text,
    status text,
    enddate timestamp with time zone,
    depdate timestamp with time zone,
    startdate timestamp with time zone,
    logdate timestamp with time zone,
    channel_id character varying,
    id_job bigint NOT NULL,
    replaydate timestamp with time zone,
    log_field character varying,
    errors integer,
    lines_rejected integer,
    lines_updated integer,
    lines_input integer,
    lines_output integer,
    lines_written integer,
    lines_read integer
);

ALTER TABLE IF EXISTS public.job_log OWNER TO "ervu-dashboard";

CREATE SEQUENCE public.job_log_id_job_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS public.job_log_id_job_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE public.job_log_id_job_seq OWNED BY public.job_log.id_job;

CREATE TABLE IF NOT EXISTS public.last_recording_date (
    last_recording_date date DEFAULT now(),
    entry text
);

ALTER TABLE IF EXISTS public.last_recording_date OWNER TO "ervu-dashboard";

CREATE TABLE IF NOT EXISTS ratings.appear_subppoena (
    id_appear_subppoena bigint NOT NULL,
    id_region integer,
    appear_mil_com numeric,
    recording_date date,
    appear_mil_com_percent numeric,
    recruitment_id character(36)
);

ALTER TABLE IF EXISTS ratings.appear_subppoena OWNER TO "ervu-dashboard";

COMMENT ON TABLE ratings.appear_subppoena IS 'Явка по повестке уровень РФ';

COMMENT ON COLUMN ratings.appear_subppoena.appear_mil_com IS 'Явка в военкомат';

COMMENT ON COLUMN ratings.appear_subppoena.recording_date IS 'Дата записи';

COMMENT ON COLUMN ratings.appear_subppoena.appear_mil_com_percent IS 'Явка в военкомат в процентах';

CREATE SEQUENCE ratings.appear_subppoena_id_appear_subppoena_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS ratings.appear_subppoena_id_appear_subppoena_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE ratings.appear_subppoena_id_appear_subppoena_seq OWNED BY ratings.appear_subppoena.id_appear_subppoena;

CREATE SEQUENCE ratings."ratings.conscription_info_id_ratings.conscription_info_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS ratings."ratings.conscription_info_id_ratings.conscription_info_seq" OWNER TO "ervu-dashboard";

CREATE TABLE IF NOT EXISTS ratings.conscription_info (
    conscription_info_id bigint DEFAULT nextval('ratings."ratings.conscription_info_id_ratings.conscription_info_seq"'::regclass) NOT NULL,
    id_region integer,
    execution numeric,
    spring_autumn text,
    recording_date date,
    execution_percent numeric,
    recruitment_id character(36)
);

ALTER TABLE IF EXISTS ratings.conscription_info OWNER TO "ervu-dashboard";

COMMENT ON TABLE ratings.conscription_info IS 'Призыв уровень РФ';

COMMENT ON COLUMN ratings.conscription_info.execution IS 'Исполнение плана призыва';

COMMENT ON COLUMN ratings.conscription_info.spring_autumn IS 'Осень/весна';

COMMENT ON COLUMN ratings.conscription_info.recording_date IS 'Дата записи';

COMMENT ON COLUMN ratings.conscription_info.execution_percent IS 'Исолнение плана призыва в процентах';

CREATE TABLE IF NOT EXISTS ratings.consideration_complaint (
    id_consideration_complaint bigint NOT NULL,
    id_region integer,
    consideration_complaint numeric,
    recording_date date,
    consideration_complaint_percent numeric,
    recruitment_id character(36)
);

ALTER TABLE IF EXISTS ratings.consideration_complaint OWNER TO "ervu-dashboard";

COMMENT ON TABLE ratings.consideration_complaint IS 'Рассмотрение жалоб уровень РФ';

COMMENT ON COLUMN ratings.consideration_complaint.consideration_complaint IS 'Рассмотрение жалоб';

COMMENT ON COLUMN ratings.consideration_complaint.recording_date IS 'Дата записи';

COMMENT ON COLUMN ratings.consideration_complaint.consideration_complaint_percent IS 'Рассмотрение жалоб в процентах';

CREATE SEQUENCE ratings.consideration_complaint_id_consideration_complaint_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS ratings.consideration_complaint_id_consideration_complaint_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE ratings.consideration_complaint_id_consideration_complaint_seq OWNED BY ratings.consideration_complaint.id_consideration_complaint;

CREATE TABLE IF NOT EXISTS recruitment_campaign.appeals (
    total_appeals numeric,
    resolved numeric,
    not_resolved numeric,
    average_consideration numeric,
    average_rating numeric,
    recording_date date DEFAULT now() NOT NULL,
    resolved_percent numeric,
    not_resolved_percent numeric,
    recruitment_id character(36) NOT NULL,
    spring_autumn character varying NOT NULL
);

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

COMMENT ON COLUMN recruitment_campaign.appeals.total_appeals IS 'Получено жалоб';

COMMENT ON COLUMN recruitment_campaign.appeals.resolved IS 'Решено';

COMMENT ON COLUMN recruitment_campaign.appeals.not_resolved IS 'Не решено';

COMMENT ON COLUMN recruitment_campaign.appeals.average_consideration IS 'Время решения';

COMMENT ON COLUMN recruitment_campaign.appeals.average_rating IS 'Оценка удовлетворенности';

COMMENT ON COLUMN recruitment_campaign.appeals.recording_date IS 'Дата записи';

COMMENT ON COLUMN recruitment_campaign.appeals.resolved_percent IS 'Процент решенных';

COMMENT ON COLUMN recruitment_campaign.appeals.not_resolved_percent IS 'Процент не решенных';

CREATE TABLE IF NOT EXISTS recruitment_campaign.postponement_info (
    postponement_info_id bigint NOT NULL,
    suitable_recruit numeric,
    postponement_have_right numeric,
    postponement_granted numeric,
    recording_date date DEFAULT now(),
    postponement_have_right_percent numeric,
    postponement_granted_percent numeric,
    recruitment_id character(36),
    testspring_autumn character(36)
);

ALTER TABLE IF EXISTS recruitment_campaign.postponement_info OWNER TO "ervu-dashboard";

COMMENT ON TABLE recruitment_campaign.postponement_info IS 'статистика по отсрочке и призывам';

COMMENT ON COLUMN recruitment_campaign.postponement_info.suitable_recruit IS 'Подходят под призыв';

COMMENT ON COLUMN recruitment_campaign.postponement_info.postponement_have_right IS 'Имеют право на отсрочку';

COMMENT ON COLUMN recruitment_campaign.postponement_info.postponement_granted IS 'Предоставлена отсрочка';

COMMENT ON COLUMN recruitment_campaign.postponement_info.recording_date IS 'Дата записи';

COMMENT ON COLUMN recruitment_campaign.postponement_info.postponement_have_right_percent IS 'Процент имеющих право на отсрочку';

COMMENT ON COLUMN recruitment_campaign.postponement_info.postponement_granted_percent IS 'Процент предоставленных отсрочек';

CREATE SEQUENCE recruitment_campaign.recruitment_id_recruitment_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS recruitment_campaign.recruitment_id_recruitment_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE recruitment_campaign.recruitment_id_recruitment_seq OWNED BY recruitment_campaign.postponement_info.postponement_info_id;

CREATE TABLE IF NOT EXISTS recruitment_campaign.subpoenas (
    subpoena numeric,
    appeared numeric,
    not_appeared numeric,
    not_ap_good_reason numeric,
    ap_not_required numeric,
    restrictions_applied numeric,
    recording_date date DEFAULT now() NOT NULL,
    appeared_percent numeric,
    not_appeared_percent numeric,
    not_ap_good_reason_percent numeric,
    ap_not_required_percent numeric,
    restrictions_applied_percent numeric,
    introduced_measures numeric,
    introduced_measures_percent numeric,
    recruitment_id character(36) NOT NULL,
    rest numeric,
    spring_autumn character(36) NOT NULL,
    id_subpoena bigint NOT NULL,
    count_not_delivery numeric,
    appear_date_is_good numeric,
    not_delivery_percent numeric,
    appear_date_is_good_percent numeric
);

ALTER TABLE IF EXISTS recruitment_campaign.subpoenas OWNER TO "ervu-dashboard";

COMMENT ON TABLE recruitment_campaign.subpoenas IS 'Повестки уровень РФ';

COMMENT ON COLUMN recruitment_campaign.subpoenas.subpoena IS 'Направлено повесток';

COMMENT ON COLUMN recruitment_campaign.subpoenas.appeared IS 'Явились';

COMMENT ON COLUMN recruitment_campaign.subpoenas.not_appeared IS 'Не явились';

COMMENT ON COLUMN recruitment_campaign.subpoenas.not_ap_good_reason IS 'Не явились по уважительной причине';

COMMENT ON COLUMN recruitment_campaign.subpoenas.ap_not_required IS 'Явка не требуется';

COMMENT ON COLUMN recruitment_campaign.subpoenas.restrictions_applied IS 'Наложено ограничений';

COMMENT ON COLUMN recruitment_campaign.subpoenas.recording_date IS 'Дата записи';

COMMENT ON COLUMN recruitment_campaign.subpoenas.appeared_percent IS 'Процент явившихся';

COMMENT ON COLUMN recruitment_campaign.subpoenas.not_appeared_percent IS 'Процент не явившихся';

COMMENT ON COLUMN recruitment_campaign.subpoenas.not_ap_good_reason_percent IS 'Процент не явившихся по уважительной причине';

COMMENT ON COLUMN recruitment_campaign.subpoenas.ap_not_required_percent IS 'Процент тех, где явка не требуется';

COMMENT ON COLUMN recruitment_campaign.subpoenas.restrictions_applied_percent IS 'Наложено ограничений';

COMMENT ON COLUMN recruitment_campaign.subpoenas.introduced_measures IS 'Введено реализатором мер';

COMMENT ON COLUMN recruitment_campaign.subpoenas.introduced_measures_percent IS 'Процент введенных реализатором мер';

COMMENT ON COLUMN recruitment_campaign.subpoenas.rest IS 'Остальные';

COMMENT ON COLUMN recruitment_campaign.subpoenas.appear_date_is_good IS 'Повестки, дата явки по которым еще не наступила';

COMMENT ON COLUMN recruitment_campaign.subpoenas.not_delivery_percent IS 'Процент не врученных повесток';

COMMENT ON COLUMN recruitment_campaign.subpoenas.appear_date_is_good_percent IS 'Процент повесток, по которым дата явки еще не наступила';

CREATE SEQUENCE recruitment_campaign.subpoenas_id_subpoena_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS recruitment_campaign.subpoenas_id_subpoena_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE recruitment_campaign.subpoenas_id_subpoena_seq OWNED BY recruitment_campaign.subpoenas.id_subpoena;

CREATE TABLE IF NOT EXISTS space.military_commissariat (
    id_military_commissariat bigint NOT NULL,
    military_commissariat_name text
);

ALTER TABLE IF EXISTS space.military_commissariat OWNER TO "ervu-dashboard";

COMMENT ON TABLE space.military_commissariat IS 'Военные комиссариаты';

COMMENT ON COLUMN space.military_commissariat.military_commissariat_name IS 'Наименование военного комиссариата';

CREATE SEQUENCE space.military_commissariat_id_military_commissariat_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS space.military_commissariat_id_military_commissariat_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE space.military_commissariat_id_military_commissariat_seq OWNED BY space.military_commissariat.id_military_commissariat;

CREATE TABLE IF NOT EXISTS space.military_district (
    id_military_district bigint NOT NULL,
    military_district_name text
);

ALTER TABLE IF EXISTS space.military_district OWNER TO "ervu-dashboard";

COMMENT ON TABLE space.military_district IS 'Военные округа';

COMMENT ON COLUMN space.military_district.military_district_name IS 'Наименование военного округа';

CREATE SEQUENCE space.military_district_id_military_district_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS space.military_district_id_military_district_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE space.military_district_id_military_district_seq OWNED BY space.military_district.id_military_district;

CREATE TABLE IF NOT EXISTS space.region (
    id_region bigint NOT NULL,
    region text
);

ALTER TABLE IF EXISTS space.region OWNER TO "ervu-dashboard";

COMMENT ON TABLE space.region IS 'Регионы';

COMMENT ON COLUMN space.region.region IS 'Наименование региона';

CREATE SEQUENCE space.region_id_region_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS space.region_id_region_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE space.region_id_region_seq OWNED BY space.region.id_region;

CREATE TABLE IF NOT EXISTS space.testrecruitment (
    id character(36) NOT NULL,
    shortname character(300),
    idm_id character varying(36),
    code character(300),
    parent_id character(300)
);

ALTER TABLE IF EXISTS space.testrecruitment OWNER TO "ervu-dashboard";

CREATE TABLE IF NOT EXISTS space.ztestrecruitment (
    id uuid,
    name text
);

ALTER TABLE IF EXISTS space.ztestrecruitment OWNER TO "ervu-dashboard";

CREATE TABLE IF NOT EXISTS total_registered.age (
    "17_years" numeric,
    "18-26_years" numeric,
    "27-30_years" numeric,
    "31-35_years" numeric,
    "36-40_years" numeric,
    "41-45_years" numeric,
    "46-50_years" numeric,
    "51+_years" numeric,
    "all_M_W" character(10) NOT NULL,
    recording_date date DEFAULT now() NOT NULL,
    "17_years_percent" numeric,
    "18-26_years_percent" numeric,
    "27-30_years_percent" numeric,
    "31-35_years_percent" numeric,
    "36-40_years_percent" numeric,
    "41-45_years_percent" numeric,
    "46-50_years_percent" numeric,
    "51+_years_percent" numeric,
    recruitment_id character(36) NOT NULL,
    registered character(10) NOT NULL,
    id_age bigint NOT NULL
);

ALTER TABLE IF EXISTS total_registered.age OWNER TO "ervu-dashboard";

COMMENT ON TABLE total_registered.age IS 'Возраст состоящих/не состоящих, мужчин/женщин/всех на учете уровень РФ';

COMMENT ON COLUMN total_registered.age."17_years" IS 'Возраст 17';

COMMENT ON COLUMN total_registered.age."18-26_years" IS 'Возраст 18-26';

COMMENT ON COLUMN total_registered.age."27-30_years" IS 'Возраст 27-30';

COMMENT ON COLUMN total_registered.age."31-35_years" IS 'Возраст 31-35';

COMMENT ON COLUMN total_registered.age."36-40_years" IS 'Возраст 36-40';

COMMENT ON COLUMN total_registered.age."41-45_years" IS 'Возраст 41-45';

COMMENT ON COLUMN total_registered.age."51+_years" IS 'Возраст 51+';

COMMENT ON COLUMN total_registered.age."all_M_W" IS 'Все/мужчины/женщины';

COMMENT ON COLUMN total_registered.age.recording_date IS 'Дата записи';

COMMENT ON COLUMN total_registered.age."46-50_years" IS 'Возраст 46-50';

COMMENT ON COLUMN total_registered.age."17_years_percent" IS 'Возраст 17 в процентах';

COMMENT ON COLUMN total_registered.age."18-26_years_percent" IS 'Возраст 18-26 в процентах';

COMMENT ON COLUMN total_registered.age."27-30_years_percent" IS 'Возраст 27-30 в процентах';

COMMENT ON COLUMN total_registered.age."31-35_years_percent" IS 'Возраст 31-35 в процентах';

COMMENT ON COLUMN total_registered.age."36-40_years_percent" IS 'Возраст 36-40 в процентах';

COMMENT ON COLUMN total_registered.age."41-45_years_percent" IS 'Возраст 41-45 в процентах';

COMMENT ON COLUMN total_registered.age."46-50_years_percent" IS 'Возраст 46-50 в процентах';

COMMENT ON COLUMN total_registered.age."51+_years_percent" IS 'Возраст 51+ в процентах';

CREATE SEQUENCE total_registered.age_id_age_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS total_registered.age_id_age_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE total_registered.age_id_age_seq OWNED BY total_registered.age.id_age;

CREATE TABLE IF NOT EXISTS total_registered.busyness (
    study numeric,
    work numeric,
    not_work numeric,
    recording_date date DEFAULT now() NOT NULL,
    study_percent numeric,
    work_percent numeric,
    not_work_percent numeric,
    recruitment_id character(36) NOT NULL,
    registered character varying NOT NULL,
    "all_M_W" character varying NOT NULL,
    busyness numeric
);

ALTER TABLE IF EXISTS total_registered.busyness OWNER TO "ervu-dashboard";

COMMENT ON TABLE total_registered.busyness IS 'Занятость состоящих/не состоящих, мужчин/женщин/всех на учете уровень РФ';

COMMENT ON COLUMN total_registered.busyness.study IS 'Учатся';

COMMENT ON COLUMN total_registered.busyness.work IS 'Работают';

COMMENT ON COLUMN total_registered.busyness.not_work IS 'Безработные';

COMMENT ON COLUMN total_registered.busyness.recording_date IS 'Дата записи';

COMMENT ON COLUMN total_registered.busyness.study_percent IS 'Учатся в процентах';

COMMENT ON COLUMN total_registered.busyness.work_percent IS 'Работают в процентах';

COMMENT ON COLUMN total_registered.busyness.not_work_percent IS 'Безработные в процентах';

CREATE TABLE IF NOT EXISTS total_registered.child_minor
(
    no_child numeric,
    "1_child" numeric,
    "2_child" numeric,
    "3_child" numeric,
    "4_more_child" numeric,
    "all_M_W" character(10) NOT NULL,
    recording_date date DEFAULT now() NOT NULL,
    no_child_percent numeric,
    "1_child_percent" numeric,
    "2_child_percent" numeric,
    "3_child_percent" numeric,
    "4_more_child_percent" numeric,
    recruitment_id character(36) NOT NULL,
    id_child_minor bigint NOT NULL
);

ALTER TABLE IF EXISTS total_registered.child_minor OWNER TO "ervu-dashboard";

COMMENT ON TABLE total_registered.child_minor IS 'Дети то 18 лет состоящих/не состоящих, мужчин/женщин/всех на учете уровень РФ';

COMMENT ON COLUMN total_registered.child_minor.no_child IS 'Нет детей';

COMMENT ON COLUMN total_registered.child_minor."1_child" IS '1 ребенок';

COMMENT ON COLUMN total_registered.child_minor."2_child" IS '2 ребенка';

COMMENT ON COLUMN total_registered.child_minor."3_child" IS '3 ребенка';

COMMENT ON COLUMN total_registered.child_minor."4_more_child" IS '4 и более';

COMMENT ON COLUMN total_registered.child_minor."all_M_W" IS 'Все/Мужчины/Женщины';

COMMENT ON COLUMN total_registered.child_minor.recording_date IS 'Дата записи';

COMMENT ON COLUMN total_registered.child_minor.no_child_percent IS 'Нет детей в процентах';

COMMENT ON COLUMN total_registered.child_minor."1_child_percent" IS '1 ребенок в процентах';

COMMENT ON COLUMN total_registered.child_minor."2_child_percent" IS '2 ребенка в процентах';

COMMENT ON COLUMN total_registered.child_minor."3_child_percent" IS '3 ребенка в процентах';

COMMENT ON COLUMN total_registered.child_minor."4_more_child_percent" IS '4 и более ребенка в процентах';

CREATE SEQUENCE total_registered.child_minor_id_child_minor_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS total_registered.child_minor_id_child_minor_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE total_registered.child_minor_id_child_minor_seq OWNED BY total_registered.child_minor.id_child_minor;

CREATE TABLE IF NOT EXISTS total_registered.driver_license
(
    nope numeric,
    "A" numeric,
    "B" numeric,
    "C" numeric,
    "D" numeric,
    "E" numeric,
    "all_M_W" character(10) NOT NULL,
    recording_date date DEFAULT now() NOT NULL,
    nope_repcent numeric,
    "A_repcent" numeric,
    "B_repcent" numeric,
    "C_repcent" numeric,
    "D_repcent" numeric,
    "E_repcent" numeric,
    recruitment_id character(36) NOT NULL,
    id_driver_license bigint NOT NULL
);

ALTER TABLE IF EXISTS total_registered.driver_license OWNER TO "ervu-dashboard";

COMMENT ON TABLE total_registered.driver_license IS 'Наличие водительского удостоверения состоящих/не состоящих, мужчин/женщин/всех на учете уровень РФ';

COMMENT ON COLUMN total_registered.driver_license.nope IS 'нет водительского удостоверения';

COMMENT ON COLUMN total_registered.driver_license."A" IS 'категория A';

COMMENT ON COLUMN total_registered.driver_license."B" IS 'категория B';

COMMENT ON COLUMN total_registered.driver_license."C" IS 'категория C';

COMMENT ON COLUMN total_registered.driver_license."D" IS 'категория D';

COMMENT ON COLUMN total_registered.driver_license."E" IS 'категория E';

COMMENT ON COLUMN total_registered.driver_license."all_M_W" IS 'Все/Мужчины/Женщины';

COMMENT ON COLUMN total_registered.driver_license.recording_date IS 'Дата записи';

COMMENT ON COLUMN total_registered.driver_license.nope_repcent IS 'нет водительского удостоверения в процентах';

COMMENT ON COLUMN total_registered.driver_license."A_repcent" IS 'категория A в процентах';

COMMENT ON COLUMN total_registered.driver_license."B_repcent" IS 'категория B в процентах';

COMMENT ON COLUMN total_registered.driver_license."C_repcent" IS 'категория C в процентах';

COMMENT ON COLUMN total_registered.driver_license."D_repcent" IS 'категория D в процентах';

COMMENT ON COLUMN total_registered.driver_license."E_repcent" IS 'категория E в процентах';

CREATE SEQUENCE total_registered.driver_license_id_driver_license_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS total_registered.driver_license_id_driver_license_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE total_registered.driver_license_id_driver_license_seq OWNED BY total_registered.driver_license.id_driver_license;

CREATE TABLE IF NOT EXISTS total_registered.education_level
(
    higher numeric,
    average numeric,
    "all_M_W" text NOT NULL,
    only_general numeric,
    no_data numeric,
    recording_date date DEFAULT now() NOT NULL,
    higher_percent numeric,
    average_percent numeric,
    only_general_percent numeric,
    no_data_percent numeric,
    recruitment_id character(36) NOT NULL,
    education_level numeric
);

ALTER TABLE IF EXISTS total_registered.education_level OWNER TO "ervu-dashboard";

COMMENT ON TABLE total_registered.education_level IS 'Уровень образования состоящих/не состоящих, мужчин/женщин/всех на учете уровень РФ';

COMMENT ON COLUMN total_registered.education_level.higher IS 'Высшее образование';

COMMENT ON COLUMN total_registered.education_level.average IS 'Среднее профессиональное';

COMMENT ON COLUMN total_registered.education_level."all_M_W" IS 'Все/Мужчины/Женщины';

COMMENT ON COLUMN total_registered.education_level.only_general IS 'Только общее';

COMMENT ON COLUMN total_registered.education_level.no_data IS 'Нет данных';

COMMENT ON COLUMN total_registered.education_level.recording_date IS 'Дата записи';

COMMENT ON COLUMN total_registered.education_level.higher_percent IS 'Высшее образование в процентах';

COMMENT ON COLUMN total_registered.education_level.average_percent IS 'Среднее профессиональное в процентах';

COMMENT ON COLUMN total_registered.education_level.only_general_percent IS 'Только общее в процентах';

COMMENT ON COLUMN total_registered.education_level.no_data_percent IS 'Нет данных об образованиии в процентах';

CREATE TABLE IF NOT EXISTS total_registered.marital_status
(
    married numeric,
    not_married numeric,
    "all_M_W" text NOT NULL,
    recording_date date DEFAULT now() NOT NULL,
    married_percent numeric,
    not_married_percent numeric,
    recruitment_id character(36) NOT NULL,
    marital_status numeric
);

ALTER TABLE IF EXISTS total_registered.marital_status OWNER TO "ervu-dashboard";

COMMENT ON TABLE total_registered.marital_status IS 'Семейное положение состоящих/не состоящих, мужчин/женщин/всех на учете уровень РФ';

COMMENT ON COLUMN total_registered.marital_status.married IS 'В браке';

COMMENT ON COLUMN total_registered.marital_status.not_married IS 'Холост';

COMMENT ON COLUMN total_registered.marital_status."all_M_W" IS 'Все/Мужчины/Женщины';

COMMENT ON COLUMN total_registered.marital_status.recording_date IS 'Дата записи';

COMMENT ON COLUMN total_registered.marital_status.married_percent IS 'В браке в процентах';

COMMENT ON COLUMN total_registered.marital_status.not_married_percent IS 'Холост в процентах';

CREATE TABLE IF NOT EXISTS total_registered.reg_mil_cat
(
    first_reg_17 numeric,
    first_reg_18 numeric,
    returned_dep_liberty numeric,
    "mil_spec_W" numeric,
    punished numeric,
    received_citizenship numeric,
    recording_date date DEFAULT now() NOT NULL,
    first_reg_17_percent numeric,
    first_reg_18_percent numeric,
    returned_dep_liberty_percent numeric,
    "mil_spec_W_percent" numeric,
    punished_percent numeric,
    received_citizenship_percent numeric,
    recruitment_id character(36) NOT NULL,
    mil_reg numeric NOT NULL,
    id_reg_mil_cat bigint NOT NULL
);

ALTER TABLE IF EXISTS total_registered.reg_mil_cat OWNER TO "ervu-dashboard";

COMMENT ON TABLE total_registered.reg_mil_cat IS 'Категории постановки на воинский учет состоящих/не состоящих на учете уровень РФ';

COMMENT ON COLUMN total_registered.reg_mil_cat.first_reg_17 IS 'Первоначальная постановка на воинский учет граждан от 17 лет';

COMMENT ON COLUMN total_registered.reg_mil_cat.first_reg_18 IS 'Первоначальная постановка на воинский учет граждан от 18 лет';

COMMENT ON COLUMN total_registered.reg_mil_cat.returned_dep_liberty IS 'Возвратившиеся из мест лишения свободы';

COMMENT ON COLUMN total_registered.reg_mil_cat."mil_spec_W" IS 'Женщины, получившие ВУС';

COMMENT ON COLUMN total_registered.reg_mil_cat.punished IS 'Отбывающие наказание в местах лишения свободы';

COMMENT ON COLUMN total_registered.reg_mil_cat.received_citizenship IS 'Получившие гражданство';

COMMENT ON COLUMN total_registered.reg_mil_cat.recording_date IS 'Дата записи';

COMMENT ON COLUMN total_registered.reg_mil_cat.first_reg_17_percent IS 'Первоначальная постановка на воинский учет граждан от 17 лет в процентах';

COMMENT ON COLUMN total_registered.reg_mil_cat.first_reg_18_percent IS 'Первоначальная постановка на воинский учет граждан от 18 лет в процентах';

COMMENT ON COLUMN total_registered.reg_mil_cat.returned_dep_liberty_percent IS 'Возвратившиеся из мест лишения свободы в процентах';

COMMENT ON COLUMN total_registered.reg_mil_cat."mil_spec_W_percent" IS 'Женщины, получившие ВУС в процентах';

COMMENT ON COLUMN total_registered.reg_mil_cat.punished_percent IS 'Отбывающие наказание в местах лишения свободы в процентах';

COMMENT ON COLUMN total_registered.reg_mil_cat.received_citizenship_percent IS 'Получившие гражданство в процентах';

CREATE SEQUENCE total_registered.reg_mil_cat_id_reg_mil_cat_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS total_registered.reg_mil_cat_id_reg_mil_cat_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE total_registered.reg_mil_cat_id_reg_mil_cat_seq OWNED BY total_registered.reg_mil_cat.id_reg_mil_cat;

CREATE TABLE IF NOT EXISTS total_registered.removed_registry
(
    removed_registry numeric,
    deprivation_citizenship numeric,
    age_limit numeric,
    death numeric,
    travel_abroad numeric,
    living_abroad numeric,
    other numeric,
    recording_date date DEFAULT now() NOT NULL,
    deprivation_citizen_percents numeric,
    age_limit_percent numeric,
    death_percent numeric,
    travel_abroad_percent numeric,
    living_abroad_percent numeric,
    other_percent numeric,
    recruitment_id character(36) NOT NULL,
    id_removed_registry bigint NOT NULL
);

ALTER TABLE IF EXISTS total_registered.removed_registry OWNER TO "ervu-dashboard";

COMMENT ON TABLE total_registered.removed_registry IS 'Снято с учета уровень РФ';

COMMENT ON COLUMN total_registered.removed_registry.removed_registry IS 'Снято с учета';

COMMENT ON COLUMN total_registered.removed_registry.deprivation_citizenship IS 'Лишение гражданства';

COMMENT ON COLUMN total_registered.removed_registry.age_limit IS 'Наступление предельного возраста';

COMMENT ON COLUMN total_registered.removed_registry.death IS 'Смерть';

COMMENT ON COLUMN total_registered.removed_registry.travel_abroad IS 'Выезд за границу на срок более 6 месяцев';

COMMENT ON COLUMN total_registered.removed_registry.living_abroad IS 'Проживающие за границей';

COMMENT ON COLUMN total_registered.removed_registry.other IS 'Прочее';

COMMENT ON COLUMN total_registered.removed_registry.recording_date IS 'Дата записи';

COMMENT ON COLUMN total_registered.removed_registry.deprivation_citizen_percents IS 'Лишение гражданства в процентах';

COMMENT ON COLUMN total_registered.removed_registry.age_limit_percent IS 'Наступление предельного возраста в процентах';

COMMENT ON COLUMN total_registered.removed_registry.death_percent IS 'Смерть в процентах';

COMMENT ON COLUMN total_registered.removed_registry.travel_abroad_percent IS 'Выезд за границу на срок более 6 месяцев в процентах';

COMMENT ON COLUMN total_registered.removed_registry.living_abroad_percent IS 'Проживающие за границей в процентах';

COMMENT ON COLUMN total_registered.removed_registry.other_percent IS 'Прочее в процентах';

CREATE SEQUENCE total_registered.removed_registry_id_removed_registry_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS total_registered.removed_registry_id_removed_registry_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE total_registered.removed_registry_id_removed_registry_seq OWNED BY total_registered.removed_registry.id_removed_registry;

CREATE TABLE IF NOT EXISTS total_registered.subpoenas
(
    subpoena numeric,
    average_appeared numeric,
    appeared numeric,
    not_appeared numeric,
    not_ap_good_reason numeric,
    ap_not_required numeric,
    electron numeric,
    paper numeric,
    restrictions_applied numeric,
    introduced_measures numeric,
    recording_date date DEFAULT now() NOT NULL,
    appeared_percent numeric,
    not_appeared_percent numeric,
    not_ap_good_reason_percent numeric,
    ap_not_required_percent numeric,
    electron_percent numeric,
    paper_percent numeric,
    restrictions_applied_percent numeric,
    introduced_measures_percent numeric,
    recruitment_id character(36) NOT NULL,
    mil_reg numeric NOT NULL,
    id_subpoena bigint NOT NULL,
    count_not_delivery numeric,
    appear_date_is_good numeric,
    not_delivery_percent numeric,
    appear_date_is_good_percent numeric
);

ALTER TABLE IF EXISTS total_registered.subpoenas OWNER TO "ervu-dashboard";

COMMENT ON TABLE total_registered.subpoenas IS 'Повестки состоящих/не состоящих на учете уровень РФ';

COMMENT ON COLUMN total_registered.subpoenas.subpoena IS 'Направлено повесток';

COMMENT ON COLUMN total_registered.subpoenas.average_appeared IS 'Средний срок явки';

COMMENT ON COLUMN total_registered.subpoenas.appeared IS 'Явились';

COMMENT ON COLUMN total_registered.subpoenas.not_appeared IS 'Не явились';

COMMENT ON COLUMN total_registered.subpoenas.not_ap_good_reason IS 'Не явились по уважительной причине';

COMMENT ON COLUMN total_registered.subpoenas.ap_not_required IS 'Явка не требуется';

COMMENT ON COLUMN total_registered.subpoenas.electron IS 'Электронно';

COMMENT ON COLUMN total_registered.subpoenas.paper IS 'Нарочно';

COMMENT ON COLUMN total_registered.subpoenas.restrictions_applied IS 'Применено ограничений';

COMMENT ON COLUMN total_registered.subpoenas.introduced_measures IS 'Введено реализатором мер';

COMMENT ON COLUMN total_registered.subpoenas.recording_date IS 'Дата записи';

COMMENT ON COLUMN total_registered.subpoenas.appeared_percent IS 'Явились в процентах';

COMMENT ON COLUMN total_registered.subpoenas.not_appeared_percent IS 'Не явились в процентах';

COMMENT ON COLUMN total_registered.subpoenas.not_ap_good_reason_percent IS 'Не явились по уважительной причине в процентах';

COMMENT ON COLUMN total_registered.subpoenas.ap_not_required_percent IS 'Явка не требуется в процентах';

COMMENT ON COLUMN total_registered.subpoenas.electron_percent IS 'Электронно в процентах';

COMMENT ON COLUMN total_registered.subpoenas.paper_percent IS 'Нарочно в процентах';

COMMENT ON COLUMN total_registered.subpoenas.restrictions_applied_percent IS 'Применено ограничений в процентах';

COMMENT ON COLUMN total_registered.subpoenas.introduced_measures_percent IS 'Введено реализатором мер в процентах';

COMMENT ON COLUMN total_registered.subpoenas.count_not_delivery IS 'Количество не врученных повесток';

COMMENT ON COLUMN total_registered.subpoenas.appear_date_is_good IS 'Повестки, дата явки по которым еще не наступила';

COMMENT ON COLUMN total_registered.subpoenas.not_delivery_percent IS 'Процент не врученных повесток';

COMMENT ON COLUMN total_registered.subpoenas.appear_date_is_good_percent IS 'Процент повесток, дата явки по которым еще не наступила';

CREATE SEQUENCE total_registered.subpoenas_id_subpoena_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE CACHE 1;

ALTER TABLE IF EXISTS total_registered.subpoenas_id_subpoena_seq OWNER TO "ervu-dashboard";

ALTER SEQUENCE total_registered.subpoenas_id_subpoena_seq OWNED BY total_registered.subpoenas.id_subpoena;

ALTER TABLE IF EXISTS ONLY appeals.main_profile ALTER COLUMN id_main_profile SET DEFAULT nextval('appeals.main_profile_id_main_profile_seq'::regclass);

ALTER TABLE IF EXISTS ONLY appeals.reasons_appeal ALTER COLUMN id_reasons_appeal SET DEFAULT nextval('appeals.reasons_appeal_id_reasons_appeal_seq'::regclass);

ALTER TABLE IF EXISTS ONLY appeals.review_rating ALTER COLUMN id_review_rating SET DEFAULT nextval('appeals.review_rating_id_review_rating_seq'::regclass);

ALTER TABLE IF EXISTS ONLY appeals.topic_appeal ALTER COLUMN id_topic_appeal SET DEFAULT nextval('appeals.topic_appeal_id_topic_appeal_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizen_child ALTER COLUMN citizen_child_id SET DEFAULT nextval('ervu_dashboard.citizen_child_citizen_child_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizen_guardianship ALTER COLUMN citizen_guardianship_id SET DEFAULT nextval('ervu_dashboard.citizen_guardianship_citizen_guardianship_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizen_spouse ALTER COLUMN citizen_spouse_id SET DEFAULT nextval('ervu_dashboard.citizen_spouse_citizen_spouse_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizenship ALTER COLUMN citizenship_id SET DEFAULT nextval('ervu_dashboard.citizenship_citizenship_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizenship_foreign ALTER COLUMN citizenship_foreign_id SET DEFAULT nextval('ervu_dashboard.citizenship_foreign_citizenship_foreign_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.decision ALTER COLUMN decision_id SET DEFAULT nextval('ervu_dashboard.decision_decision_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.deputy ALTER COLUMN deputy_id SET DEFAULT nextval('ervu_dashboard.deputy_deputy_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.disability ALTER COLUMN disability_id SET DEFAULT nextval('ervu_dashboard.disability_disability_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.disease ALTER COLUMN disease_id SET DEFAULT nextval('ervu_dashboard.disease_disease_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.drivers_licence ALTER COLUMN drivers_licence_id SET DEFAULT nextval('ervu_dashboard.drivers_licence_drivers_licence_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.medical_authorities ALTER COLUMN medical_authorities_id SET DEFAULT nextval('ervu_dashboard.medical_authorities_medical_authorities_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.passport ALTER COLUMN passport_id SET DEFAULT nextval('ervu_dashboard.passport_passport_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.property ALTER COLUMN property_id SET DEFAULT nextval('ervu_dashboard.property_property_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.prosecution ALTER COLUMN prosecution_id SET DEFAULT nextval('ervu_dashboard.prosecution_prosecution_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.punishment ALTER COLUMN punishment_id SET DEFAULT nextval('ervu_dashboard.punishment_punishment_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.work ALTER COLUMN work_id SET DEFAULT nextval('ervu_dashboard.work_work_id_seq'::regclass);

ALTER TABLE IF EXISTS ONLY main_dashboard.appeals ALTER COLUMN id_appeal SET DEFAULT nextval('main_dashboard.appeals_id_appeal_seq'::regclass);

ALTER TABLE IF EXISTS ONLY main_dashboard.recruitment_campaign ALTER COLUMN id_recruitment_campaign SET DEFAULT nextval('main_dashboard.recruitment_campaign_id_recruitment_campaign_seq'::regclass);

ALTER TABLE IF EXISTS ONLY main_dashboard.total_registered ALTER COLUMN id_total_registered SET DEFAULT nextval('main_dashboard.total_registered_id_total_registered_seq'::regclass);

ALTER TABLE IF EXISTS ONLY main_dashboard.waiting_registration ALTER COLUMN id_waiting_registration SET DEFAULT nextval('main_dashboard.waiting_registration_id_waiting_registration_seq'::regclass);

ALTER TABLE IF EXISTS ONLY public.job_log ALTER COLUMN id_job SET DEFAULT nextval('public.job_log_id_job_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ratings.appear_subppoena ALTER COLUMN id_appear_subppoena SET DEFAULT nextval('ratings.appear_subppoena_id_appear_subppoena_seq'::regclass);

ALTER TABLE IF EXISTS ONLY ratings.consideration_complaint ALTER COLUMN id_consideration_complaint SET DEFAULT nextval('ratings.consideration_complaint_id_consideration_complaint_seq'::regclass);

ALTER TABLE IF EXISTS ONLY recruitment_campaign.postponement_info ALTER COLUMN postponement_info_id SET DEFAULT nextval('recruitment_campaign.recruitment_id_recruitment_seq'::regclass);

ALTER TABLE IF EXISTS ONLY recruitment_campaign.subpoenas ALTER COLUMN id_subpoena SET DEFAULT nextval('recruitment_campaign.subpoenas_id_subpoena_seq'::regclass);

ALTER TABLE IF EXISTS ONLY space.military_commissariat ALTER COLUMN id_military_commissariat SET DEFAULT nextval('space.military_commissariat_id_military_commissariat_seq'::regclass);

ALTER TABLE IF EXISTS ONLY space.military_district ALTER COLUMN id_military_district SET DEFAULT nextval('space.military_district_id_military_district_seq'::regclass);

ALTER TABLE IF EXISTS ONLY space.region ALTER COLUMN id_region SET DEFAULT nextval('space.region_id_region_seq'::regclass);

ALTER TABLE IF EXISTS ONLY total_registered.age ALTER COLUMN id_age SET DEFAULT nextval('total_registered.age_id_age_seq'::regclass);

ALTER TABLE IF EXISTS ONLY total_registered.child_minor ALTER COLUMN id_child_minor SET DEFAULT nextval('total_registered.child_minor_id_child_minor_seq'::regclass);

ALTER TABLE IF EXISTS ONLY total_registered.driver_license ALTER COLUMN id_driver_license SET DEFAULT nextval('total_registered.driver_license_id_driver_license_seq'::regclass);

ALTER TABLE IF EXISTS ONLY total_registered.reg_mil_cat ALTER COLUMN id_reg_mil_cat SET DEFAULT nextval('total_registered.reg_mil_cat_id_reg_mil_cat_seq'::regclass);

ALTER TABLE IF EXISTS ONLY total_registered.removed_registry ALTER COLUMN id_removed_registry SET DEFAULT nextval('total_registered.removed_registry_id_removed_registry_seq'::regclass);

ALTER TABLE IF EXISTS ONLY total_registered.subpoenas ALTER COLUMN id_subpoena SET DEFAULT nextval('total_registered.subpoenas_id_subpoena_seq'::regclass);

ALTER TABLE IF EXISTS ONLY appeals.main_profile
    ADD CONSTRAINT pk_main_profile PRIMARY KEY (id_main_profile);

ALTER TABLE IF EXISTS ONLY appeals.reasons_appeal
    ADD CONSTRAINT pk_reasons_appeal PRIMARY KEY (id_reasons_appeal);

ALTER TABLE IF EXISTS ONLY appeals.review_rating
    ADD CONSTRAINT pk_review_rating PRIMARY KEY (id_review_rating);

ALTER TABLE IF EXISTS ONLY appeals.topic_appeal
    ADD CONSTRAINT pk_topic_appeal PRIMARY KEY (id_topic_appeal);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizen
    ADD CONSTRAINT citizen_pkey PRIMARY KEY (recruit_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.decision
    ADD CONSTRAINT decision_pkey PRIMARY KEY (decision_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizen_child
    ADD CONSTRAINT pk_citizen_child PRIMARY KEY (citizen_child_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizen_guardianship
    ADD CONSTRAINT pk_citizen_guardianship PRIMARY KEY (citizen_guardianship_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizen_spouse
    ADD CONSTRAINT pk_citizen_spouse PRIMARY KEY (citizen_spouse_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizenship
    ADD CONSTRAINT pk_citizenship PRIMARY KEY (citizenship_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.citizenship_foreign
    ADD CONSTRAINT pk_citizenship_foreign PRIMARY KEY (citizenship_foreign_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.deputy
    ADD CONSTRAINT pk_deputy PRIMARY KEY (deputy_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.disability
    ADD CONSTRAINT pk_disability PRIMARY KEY (disability_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.disease
    ADD CONSTRAINT pk_disease PRIMARY KEY (disease_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.drivers_licence
    ADD CONSTRAINT pk_drivers_licence PRIMARY KEY (drivers_licence_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.medical_authorities
    ADD CONSTRAINT pk_medical_authorities PRIMARY KEY (medical_authorities_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.passport
    ADD CONSTRAINT pk_passport PRIMARY KEY (passport_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.property
    ADD CONSTRAINT pk_property PRIMARY KEY (property_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.prosecution
    ADD CONSTRAINT pk_prosecution PRIMARY KEY (prosecution_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.punishment
    ADD CONSTRAINT pk_punishment PRIMARY KEY (punishment_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.work
    ADD CONSTRAINT pk_work PRIMARY KEY (work_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.pub_recruitment
    ADD CONSTRAINT pub_recruitment_pkey PRIMARY KEY (id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.pub_recruitment
    ADD CONSTRAINT recruitment_idm_id_key UNIQUE (idm_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.recruitment
    ADD CONSTRAINT recruitment_pkey PRIMARY KEY (id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.subpoena
    ADD CONSTRAINT subpoena_pkey PRIMARY KEY (sub_id);

ALTER TABLE IF EXISTS ONLY ervu_dashboard.temporary_measures
    ADD CONSTRAINT temporary_measures_pkey PRIMARY KEY (temporary_measures_id);

ALTER TABLE IF EXISTS ONLY main_dashboard.appeals
    ADD CONSTRAINT appeals_pkey PRIMARY KEY (recruitment_id, recording_date);

ALTER TABLE IF EXISTS ONLY main_dashboard.recruitment_campaign
    ADD CONSTRAINT recruitment_campaign_pkey PRIMARY KEY (spring_autumn, recruitment_id, recording_date);

ALTER TABLE IF EXISTS ONLY main_dashboard.total_registered
    ADD CONSTRAINT total_registered_pkey PRIMARY KEY (recruitment_id, recording_date);

ALTER TABLE IF EXISTS ONLY main_dashboard.waiting_registration
    ADD CONSTRAINT waiting_registration_pkey PRIMARY KEY (recruitment_id, recording_date);

ALTER TABLE IF EXISTS ONLY public.job_log
    ADD CONSTRAINT job_log_pkey PRIMARY KEY (id_job);

ALTER TABLE IF EXISTS ONLY ratings.appear_subppoena
    ADD CONSTRAINT pk_appear_subppoena PRIMARY KEY (id_appear_subppoena);

ALTER TABLE IF EXISTS ONLY ratings.conscription_info
    ADD CONSTRAINT pk_conscription_info PRIMARY KEY (conscription_info_id);

ALTER TABLE IF EXISTS ONLY ratings.consideration_complaint
    ADD CONSTRAINT pk_consideration_complaint PRIMARY KEY (id_consideration_complaint);

ALTER TABLE IF EXISTS ONLY recruitment_campaign.appeals
    ADD CONSTRAINT appeals_pkey PRIMARY KEY (recording_date, spring_autumn, recruitment_id);

ALTER TABLE IF EXISTS ONLY recruitment_campaign.postponement_info
    ADD CONSTRAINT pk_postponement_info PRIMARY KEY (postponement_info_id);

ALTER TABLE IF EXISTS ONLY recruitment_campaign.subpoenas
    ADD CONSTRAINT subpoenas_pkey PRIMARY KEY (spring_autumn, recruitment_id, recording_date);

ALTER TABLE IF EXISTS ONLY space.military_district
    ADD CONSTRAINT military_district_pkey PRIMARY KEY (id_military_district);

ALTER TABLE IF EXISTS ONLY space.military_commissariat
    ADD CONSTRAINT pk_military_commissariat PRIMARY KEY (id_military_commissariat);

ALTER TABLE IF EXISTS ONLY space.region
    ADD CONSTRAINT pk_region PRIMARY KEY (id_region);

ALTER TABLE IF EXISTS ONLY space.testrecruitment
    ADD CONSTRAINT testrecruitment_pkey PRIMARY KEY (id);

ALTER TABLE IF EXISTS ONLY total_registered.age
    ADD CONSTRAINT age_pkey PRIMARY KEY (registered, recruitment_id, recording_date, "all_M_W");

ALTER TABLE IF EXISTS ONLY total_registered.busyness
    ADD CONSTRAINT busyness_pkey PRIMARY KEY (recording_date, recruitment_id, registered, "all_M_W");

ALTER TABLE IF EXISTS ONLY total_registered.child_minor
    ADD CONSTRAINT child_minor_pkey PRIMARY KEY ("all_M_W", recording_date, recruitment_id);

ALTER TABLE IF EXISTS ONLY total_registered.driver_license
    ADD CONSTRAINT driver_license_pkey PRIMARY KEY (recruitment_id, "all_M_W", recording_date);

ALTER TABLE IF EXISTS ONLY total_registered.education_level
    ADD CONSTRAINT education_level_pkey PRIMARY KEY ("all_M_W", recording_date, recruitment_id);

ALTER TABLE IF EXISTS ONLY total_registered.marital_status
    ADD CONSTRAINT marital_status_pkey PRIMARY KEY (recruitment_id, recording_date, "all_M_W");

ALTER TABLE IF EXISTS ONLY total_registered.reg_mil_cat
    ADD CONSTRAINT reg_mil_cat_pkey PRIMARY KEY (mil_reg, recruitment_id, recording_date);

ALTER TABLE IF EXISTS ONLY total_registered.removed_registry
    ADD CONSTRAINT removed_registry_pkey PRIMARY KEY (recruitment_id, recording_date);

ALTER TABLE IF EXISTS ONLY total_registered.subpoenas
    ADD CONSTRAINT subpoenas_pkey PRIMARY KEY (mil_reg, recruitment_id, recording_date);

CREATE INDEX fki_main_profile_fk1 ON appeals.main_profile USING btree (recruitment_id);

CREATE INDEX fki_reasons_appeal_fk1 ON appeals.reasons_appeal USING btree (recruitment_id);

CREATE INDEX fki_review_rating_fk1 ON appeals.review_rating USING btree (recruitment_id);

CREATE INDEX fki_topic_appeal_fk1 ON appeals.topic_appeal USING btree (recruitment_id);

CREATE INDEX recruitment_military_code_idx ON ervu_dashboard.pub_recruitment USING btree (military_code);

CREATE INDEX recruitment_parent_idx ON ervu_dashboard.pub_recruitment USING btree (parent_id);

CREATE INDEX subpoena_send_date_idx ON ervu_dashboard.subpoena USING btree (send_date);

CREATE INDEX fki_md_appeals_fk1 ON main_dashboard.appeals USING btree (recruitment_id);

CREATE INDEX fki_recruitment_campaign_fk1 ON main_dashboard.recruitment_campaign USING btree (recruitment_id);

CREATE INDEX fki_total_registered_fk1 ON main_dashboard.total_registered USING btree (recruitment_id);

CREATE INDEX fki_waiting_registration_fk1 ON main_dashboard.waiting_registration USING btree (recruitment_id);

CREATE INDEX fki_appear_subppoena_fk1 ON ratings.appear_subppoena USING btree (recruitment_id);

CREATE INDEX fki_consideration_complaint_fk1 ON ratings.consideration_complaint USING btree (recruitment_id);

CREATE INDEX fki_recruitment_fk1 ON ratings.conscription_info USING btree (recruitment_id);

CREATE INDEX fki_rc_appeals_fk1 ON recruitment_campaign.appeals USING btree (recruitment_id);

CREATE INDEX fki_recruitment_fk1 ON recruitment_campaign.postponement_info USING btree (recruitment_id);

CREATE INDEX fki_subpoenas_fk1 ON recruitment_campaign.subpoenas USING btree (recruitment_id);

CREATE INDEX fki_age_fk1 ON total_registered.age USING btree (recruitment_id);

CREATE INDEX fki_busyness_fk1 ON total_registered.busyness USING btree (recruitment_id);

CREATE INDEX fki_child_minor_fk1 ON total_registered.child_minor USING btree (recruitment_id);

CREATE INDEX fki_driver_license_fk1 ON total_registered.driver_license USING btree (recruitment_id);

CREATE INDEX fki_education_level_fk1 ON total_registered.education_level USING btree (recruitment_id);

CREATE INDEX fki_marital_status_fk1 ON total_registered.marital_status USING btree (recruitment_id);

CREATE INDEX fki_reg_mil_cat_fk1 ON total_registered.reg_mil_cat USING btree (recruitment_id);

CREATE INDEX fki_subpoenas_fk1 ON total_registered.subpoenas USING btree (recruitment_id);

ALTER TABLE IF EXISTS ONLY appeals.review_rating
    ADD CONSTRAINT fk_region FOREIGN KEY (id_region) REFERENCES space.region(id_region) NOT VALID;

ALTER TABLE IF EXISTS ONLY appeals.main_profile
    ADD CONSTRAINT main_profile_fk1 FOREIGN KEY (recruitment_id) REFERENCES ervu_dashboard.pub_recruitment(id);

ALTER TABLE IF EXISTS ONLY appeals.reasons_appeal
    ADD CONSTRAINT reasons_appeal_fk1 FOREIGN KEY (recruitment_id) REFERENCES ervu_dashboard.pub_recruitment(id);

ALTER TABLE IF EXISTS ONLY appeals.topic_appeal
    ADD CONSTRAINT topic_appeal_fk1 FOREIGN KEY (recruitment_id) REFERENCES ervu_dashboard.pub_recruitment(id);

ALTER TABLE IF EXISTS ONLY ratings.appear_subppoena
    ADD CONSTRAINT appear_subppoena_fk1 FOREIGN KEY (recruitment_id) REFERENCES ervu_dashboard.recruitment(id);

ALTER TABLE IF EXISTS ONLY ratings.conscription_info
    ADD CONSTRAINT conscription_info_fk1 FOREIGN KEY (recruitment_id) REFERENCES ervu_dashboard.recruitment(id);

ALTER TABLE IF EXISTS ONLY ratings.conscription_info
    ADD CONSTRAINT conscription_info_fk2 FOREIGN KEY (id_region) REFERENCES space.region(id_region) NOT VALID;

ALTER TABLE IF EXISTS ONLY ratings.consideration_complaint
    ADD CONSTRAINT consideration_complaint_fk1 FOREIGN KEY (recruitment_id) REFERENCES ervu_dashboard.pub_recruitment(id);

ALTER TABLE IF EXISTS ONLY ratings.appear_subppoena
    ADD CONSTRAINT fk_region FOREIGN KEY (id_region) REFERENCES space.region(id_region) NOT VALID;

ALTER TABLE IF EXISTS ONLY ratings.consideration_complaint
    ADD CONSTRAINT fk_region FOREIGN KEY (id_region) REFERENCES space.region(id_region) NOT VALID;

ALTER TABLE IF EXISTS ONLY recruitment_campaign.postponement_info
    ADD CONSTRAINT postponement_info_fk1 FOREIGN KEY (recruitment_id) REFERENCES ervu_dashboard.recruitment(id) NOT VALID;

GRANT ALL ON SCHEMA public TO "ervu-dashboard";


