--
-- PostgreSQL database dump
--

\restrict QE5gWnMnwFD85iXfDbL0jTS26h25Rd1eZy4LqxSqz4fm75PCq2XVei8HFA4UzPy

-- Dumped from database version 18.0
-- Dumped by pg_dump version 18.0

-- Started on 2026-06-26 11:25:45

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 815 (class 1259 OID 452120)
-- Name: customers; Type: TABLE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE TABLE kotov_aa.customers (
    customerid integer NOT NULL,
    companyname character varying(100) NOT NULL,
    phone character varying(20),
    address text
);


ALTER TABLE kotov_aa.customers OWNER TO kotov_aa;

--
-- TOC entry 814 (class 1259 OID 452119)
-- Name: customers_customerid_seq; Type: SEQUENCE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE SEQUENCE kotov_aa.customers_customerid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE kotov_aa.customers_customerid_seq OWNER TO kotov_aa;

--
-- TOC entry 6564 (class 0 OID 0)
-- Dependencies: 814
-- Name: customers_customerid_seq; Type: SEQUENCE OWNED BY; Schema: kotov_aa; Owner: kotov_aa
--

ALTER SEQUENCE kotov_aa.customers_customerid_seq OWNED BY kotov_aa.customers.customerid;


--
-- TOC entry 6309 (class 2604 OID 452123)
-- Name: customers customerid; Type: DEFAULT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.customers ALTER COLUMN customerid SET DEFAULT nextval('kotov_aa.customers_customerid_seq'::regclass);


--
-- TOC entry 6558 (class 0 OID 452120)
-- Dependencies: 815
-- Data for Name: customers; Type: TABLE DATA; Schema: kotov_aa; Owner: kotov_aa
--

INSERT INTO kotov_aa.customers VALUES (1, 'ООО "Волга-Логистик"', '+7(831)455-12-89', 'г. Нижний Новгород, пр. Гагарина, 37');
INSERT INTO kotov_aa.customers VALUES (2, 'ИП Кравченко А.С.', '+7(473)200-55-11', 'г. Воронеж, ул. Кольцовская, 12Б');
INSERT INTO kotov_aa.customers VALUES (3, 'АО "Сибметалл"', '+7(391)288-77-44', 'г. Красноярск, ул. Маерчака, 5');
INSERT INTO kotov_aa.customers VALUES (4, 'ООО "ЮгАгроТорг"', '+7(861)300-11-99', 'г. Краснодар, ул. Северная, 445');
INSERT INTO kotov_aa.customers VALUES (5, 'ИП Рахимов Б.Т.', '+7(846)999-00-22', 'г. Самара, Московское ш., 18');
INSERT INTO kotov_aa.customers VALUES (6, 'ООО "ТверьСтройКомплект"', '+7(4822)57-14-33', 'г. Тверь, бул. Цанова, 21');


--
-- TOC entry 6565 (class 0 OID 0)
-- Dependencies: 814
-- Name: customers_customerid_seq; Type: SEQUENCE SET; Schema: kotov_aa; Owner: kotov_aa
--

SELECT pg_catalog.setval('kotov_aa.customers_customerid_seq', 6, true);


--
-- TOC entry 6311 (class 2606 OID 452129)
-- Name: customers customers_pkey; Type: CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.customers
    ADD CONSTRAINT customers_pkey PRIMARY KEY (customerid);


-- Completed on 2026-06-26 11:25:55

--
-- PostgreSQL database dump complete
--

\unrestrict QE5gWnMnwFD85iXfDbL0jTS26h25Rd1eZy4LqxSqz4fm75PCq2XVei8HFA4UzPy
--
-- PostgreSQL database dump
--

\restrict tZ8oysxXLLQFxpcYbfPqMirY3lnw91GyPey3ea8dTt4WCXqdhtZdV02hHdVbGG8

-- Dumped from database version 18.0
-- Dumped by pg_dump version 18.0

-- Started on 2026-06-26 11:33:50

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 817 (class 1259 OID 452131)
-- Name: cargo; Type: TABLE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE TABLE kotov_aa.cargo (
    cargoid integer NOT NULL,
    name character varying(100) NOT NULL,
    weight numeric(10,2) NOT NULL,
    CONSTRAINT cargo_weight_check CHECK ((weight > (0)::numeric))
);


ALTER TABLE kotov_aa.cargo OWNER TO kotov_aa;

--
-- TOC entry 816 (class 1259 OID 452130)
-- Name: cargo_cargoid_seq; Type: SEQUENCE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE SEQUENCE kotov_aa.cargo_cargoid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE kotov_aa.cargo_cargoid_seq OWNER TO kotov_aa;

--
-- TOC entry 6565 (class 0 OID 0)
-- Dependencies: 816
-- Name: cargo_cargoid_seq; Type: SEQUENCE OWNED BY; Schema: kotov_aa; Owner: kotov_aa
--

ALTER SEQUENCE kotov_aa.cargo_cargoid_seq OWNED BY kotov_aa.cargo.cargoid;


--
-- TOC entry 6309 (class 2604 OID 452134)
-- Name: cargo cargoid; Type: DEFAULT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.cargo ALTER COLUMN cargoid SET DEFAULT nextval('kotov_aa.cargo_cargoid_seq'::regclass);


--
-- TOC entry 6559 (class 0 OID 452131)
-- Dependencies: 817
-- Data for Name: cargo; Type: TABLE DATA; Schema: kotov_aa; Owner: kotov_aa
--

INSERT INTO kotov_aa.cargo VALUES (1, 'Кабель силовой ВВГнг 3х2.5', 1850.40);
INSERT INTO kotov_aa.cargo VALUES (2, 'Фурнитура мебельная (петли/ручки)', 420.15);
INSERT INTO kotov_aa.cargo VALUES (3, 'Трубы ПНД d110 мм', 3200.00);
INSERT INTO kotov_aa.cargo VALUES (4, 'Консервы овощные банка 0.5л', 2150.80);
INSERT INTO kotov_aa.cargo VALUES (5, 'Лакокрасочные материалы', 980.50);
INSERT INTO kotov_aa.cargo VALUES (6, 'Поддоны деревянные евро', 1100.00);


--
-- TOC entry 6566 (class 0 OID 0)
-- Dependencies: 816
-- Name: cargo_cargoid_seq; Type: SEQUENCE SET; Schema: kotov_aa; Owner: kotov_aa
--

SELECT pg_catalog.setval('kotov_aa.cargo_cargoid_seq', 6, true);


--
-- TOC entry 6312 (class 2606 OID 452140)
-- Name: cargo cargo_pkey; Type: CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.cargo
    ADD CONSTRAINT cargo_pkey PRIMARY KEY (cargoid);


-- Completed on 2026-06-26 11:34:01

--
-- PostgreSQL database dump complete
--

\unrestrict tZ8oysxXLLQFxpcYbfPqMirY3lnw91GyPey3ea8dTt4WCXqdhtZdV02hHdVbGG8
--
-- PostgreSQL database dump
--

\restrict L18SYPOpsMgKuKQZ1OZVVxUnCZt1N618XEeGMXWrxrfLiS7Bdo1QRZKg5gjUgJI

-- Dumped from database version 18.0
-- Dumped by pg_dump version 18.0

-- Started on 2026-06-26 11:36:22

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 811 (class 1259 OID 452098)
-- Name: cities; Type: TABLE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE TABLE kotov_aa.cities (
    cityid integer NOT NULL,
    name character varying(100) NOT NULL,
    region character varying(50)
);


ALTER TABLE kotov_aa.cities OWNER TO kotov_aa;

--
-- TOC entry 810 (class 1259 OID 452097)
-- Name: cities_cityid_seq; Type: SEQUENCE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE SEQUENCE kotov_aa.cities_cityid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE kotov_aa.cities_cityid_seq OWNER TO kotov_aa;

--
-- TOC entry 6564 (class 0 OID 0)
-- Dependencies: 810
-- Name: cities_cityid_seq; Type: SEQUENCE OWNED BY; Schema: kotov_aa; Owner: kotov_aa
--

ALTER SEQUENCE kotov_aa.cities_cityid_seq OWNED BY kotov_aa.cities.cityid;


--
-- TOC entry 6309 (class 2604 OID 452101)
-- Name: cities cityid; Type: DEFAULT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.cities ALTER COLUMN cityid SET DEFAULT nextval('kotov_aa.cities_cityid_seq'::regclass);


--
-- TOC entry 6558 (class 0 OID 452098)
-- Dependencies: 811
-- Data for Name: cities; Type: TABLE DATA; Schema: kotov_aa; Owner: kotov_aa
--

INSERT INTO kotov_aa.cities VALUES (1, 'Тверь', 'Тверская обл.');
INSERT INTO kotov_aa.cities VALUES (2, 'Нижний Новгород', 'Нижегородская обл.');
INSERT INTO kotov_aa.cities VALUES (3, 'Воронеж', 'Воронежская обл.');
INSERT INTO kotov_aa.cities VALUES (4, 'Самара', 'Самарская обл.');
INSERT INTO kotov_aa.cities VALUES (5, 'Красноярск', 'Красноярский край');
INSERT INTO kotov_aa.cities VALUES (6, 'Краснодар', 'Краснодарский край');


--
-- TOC entry 6565 (class 0 OID 0)
-- Dependencies: 810
-- Name: cities_cityid_seq; Type: SEQUENCE SET; Schema: kotov_aa; Owner: kotov_aa
--

SELECT pg_catalog.setval('kotov_aa.cities_cityid_seq', 6, true);


--
-- TOC entry 6311 (class 2606 OID 452105)
-- Name: cities cities_pkey; Type: CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.cities
    ADD CONSTRAINT cities_pkey PRIMARY KEY (cityid);


-- Completed on 2026-06-26 11:36:32

--
-- PostgreSQL database dump complete
--

\unrestrict L18SYPOpsMgKuKQZ1OZVVxUnCZt1N618XEeGMXWrxrfLiS7Bdo1QRZKg5gjUgJI
--
-- PostgreSQL database dump
--

\restrict GjMeXkXdIsbErgVxfIjI9OT8h0DfJ0ey6YLhPMEhdEfvmDDv0InRhviB4RJ8hE3

-- Dumped from database version 18.0
-- Dumped by pg_dump version 18.0

-- Started on 2026-06-26 11:37:55

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 813 (class 1259 OID 452107)
-- Name: drivers; Type: TABLE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE TABLE kotov_aa.drivers (
    driverid integer NOT NULL,
    lastname character varying(50) NOT NULL,
    fullname character varying(100) NOT NULL,
    tabnumber character varying(20) NOT NULL
);


ALTER TABLE kotov_aa.drivers OWNER TO kotov_aa;

--
-- TOC entry 812 (class 1259 OID 452106)
-- Name: drivers_driverid_seq; Type: SEQUENCE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE SEQUENCE kotov_aa.drivers_driverid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE kotov_aa.drivers_driverid_seq OWNER TO kotov_aa;

--
-- TOC entry 6566 (class 0 OID 0)
-- Dependencies: 812
-- Name: drivers_driverid_seq; Type: SEQUENCE OWNED BY; Schema: kotov_aa; Owner: kotov_aa
--

ALTER SEQUENCE kotov_aa.drivers_driverid_seq OWNED BY kotov_aa.drivers.driverid;


--
-- TOC entry 6309 (class 2604 OID 452110)
-- Name: drivers driverid; Type: DEFAULT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.drivers ALTER COLUMN driverid SET DEFAULT nextval('kotov_aa.drivers_driverid_seq'::regclass);


--
-- TOC entry 6560 (class 0 OID 452107)
-- Dependencies: 813
-- Data for Name: drivers; Type: TABLE DATA; Schema: kotov_aa; Owner: kotov_aa
--

INSERT INTO kotov_aa.drivers VALUES (2, 'Ковалёва', 'Марина Игоревна', 'ДРВ-5093');
INSERT INTO kotov_aa.drivers VALUES (3, 'Габдуллин', 'Рустам Фаридович', 'ДРВ-6117');
INSERT INTO kotov_aa.drivers VALUES (4, 'Ткаченко', 'Олег Витальевич', 'ДРВ-7204');
INSERT INTO kotov_aa.drivers VALUES (5, 'Белова', 'Светлана Алексеевна', 'ДРВ-8330');
INSERT INTO kotov_aa.drivers VALUES (6, 'Нурмагомедов', 'Магомед Алиевич', 'ДРВ-9115');
INSERT INTO kotov_aa.drivers VALUES (1, 'Уеков', 'Артур Дмитриевич', 'ДРВ-4821');


--
-- TOC entry 6567 (class 0 OID 0)
-- Dependencies: 812
-- Name: drivers_driverid_seq; Type: SEQUENCE SET; Schema: kotov_aa; Owner: kotov_aa
--

SELECT pg_catalog.setval('kotov_aa.drivers_driverid_seq', 8, true);


--
-- TOC entry 6311 (class 2606 OID 452116)
-- Name: drivers drivers_pkey; Type: CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.drivers
    ADD CONSTRAINT drivers_pkey PRIMARY KEY (driverid);


--
-- TOC entry 6313 (class 2606 OID 452118)
-- Name: drivers drivers_tabnumber_key; Type: CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.drivers
    ADD CONSTRAINT drivers_tabnumber_key UNIQUE (tabnumber);


-- Completed on 2026-06-26 11:38:03

--
-- PostgreSQL database dump complete
--

\unrestrict GjMeXkXdIsbErgVxfIjI9OT8h0DfJ0ey6YLhPMEhdEfvmDDv0InRhviB4RJ8hE3
--
-- PostgreSQL database dump
--

\restrict snKl38QtDmlHlRoIN2iZzdVPz9xDRgE3UIfqr4EV2SJVkb86T38fRWHnv2bex5t

-- Dumped from database version 18.0
-- Dumped by pg_dump version 18.0

-- Started on 2026-06-26 11:39:03

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 823 (class 1259 OID 452179)
-- Name: orders; Type: TABLE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE TABLE kotov_aa.orders (
    orderid integer NOT NULL,
    customerid integer NOT NULL,
    vehicleid integer NOT NULL,
    cargoid integer NOT NULL,
    routeid integer NOT NULL,
    orderdate date NOT NULL,
    plandate date NOT NULL,
    factdate date,
    status character varying(30) DEFAULT 'В пути'::character varying,
    CONSTRAINT orders_status_check CHECK (((status)::text = ANY ((ARRAY['В пути'::character varying, 'Доставлен'::character varying, 'Отменён'::character varying])::text[])))
);


ALTER TABLE kotov_aa.orders OWNER TO kotov_aa;

--
-- TOC entry 822 (class 1259 OID 452178)
-- Name: orders_orderid_seq; Type: SEQUENCE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE SEQUENCE kotov_aa.orders_orderid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE kotov_aa.orders_orderid_seq OWNER TO kotov_aa;

--
-- TOC entry 6570 (class 0 OID 0)
-- Dependencies: 822
-- Name: orders_orderid_seq; Type: SEQUENCE OWNED BY; Schema: kotov_aa; Owner: kotov_aa
--

ALTER SEQUENCE kotov_aa.orders_orderid_seq OWNED BY kotov_aa.orders.orderid;


--
-- TOC entry 6309 (class 2604 OID 452182)
-- Name: orders orderid; Type: DEFAULT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.orders ALTER COLUMN orderid SET DEFAULT nextval('kotov_aa.orders_orderid_seq'::regclass);


--
-- TOC entry 6564 (class 0 OID 452179)
-- Dependencies: 823
-- Data for Name: orders; Type: TABLE DATA; Schema: kotov_aa; Owner: kotov_aa
--

INSERT INTO kotov_aa.orders VALUES (1, 1, 1, 1, 1, '2023-11-10', '2023-11-14', '2023-11-13', 'Доставлен');
INSERT INTO kotov_aa.orders VALUES (2, 2, 2, 2, 2, '2023-12-05', '2023-12-10', '2023-12-12', 'Доставлен');
INSERT INTO kotov_aa.orders VALUES (3, 3, 3, 3, 3, '2024-01-15', '2024-01-22', NULL, 'В пути');
INSERT INTO kotov_aa.orders VALUES (4, 4, 4, 4, 4, '2024-02-01', '2024-02-08', '2024-02-07', 'Доставлен');
INSERT INTO kotov_aa.orders VALUES (5, 5, 5, 5, 5, '2024-03-10', '2024-03-18', '2024-03-21', 'Доставлен');
INSERT INTO kotov_aa.orders VALUES (6, 6, 6, 6, 6, '2024-04-05', '2024-04-12', NULL, 'В пути');
INSERT INTO kotov_aa.orders VALUES (7, 1, 2, 4, 2, '2024-05-20', '2024-05-25', '2024-05-25', 'Доставлен');


--
-- TOC entry 6571 (class 0 OID 0)
-- Dependencies: 822
-- Name: orders_orderid_seq; Type: SEQUENCE SET; Schema: kotov_aa; Owner: kotov_aa
--

SELECT pg_catalog.setval('kotov_aa.orders_orderid_seq', 7, true);


--
-- TOC entry 6313 (class 2606 OID 452193)
-- Name: orders orders_pkey; Type: CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.orders
    ADD CONSTRAINT orders_pkey PRIMARY KEY (orderid);


--
-- TOC entry 6314 (class 2606 OID 452204)
-- Name: orders orders_cargoid_fkey; Type: FK CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.orders
    ADD CONSTRAINT orders_cargoid_fkey FOREIGN KEY (cargoid) REFERENCES kotov_aa.cargo(cargoid);


--
-- TOC entry 6315 (class 2606 OID 452194)
-- Name: orders orders_customerid_fkey; Type: FK CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.orders
    ADD CONSTRAINT orders_customerid_fkey FOREIGN KEY (customerid) REFERENCES kotov_aa.customers(customerid);


--
-- TOC entry 6316 (class 2606 OID 452209)
-- Name: orders orders_routeid_fkey; Type: FK CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.orders
    ADD CONSTRAINT orders_routeid_fkey FOREIGN KEY (routeid) REFERENCES kotov_aa.routes(routeid);


--
-- TOC entry 6317 (class 2606 OID 452199)
-- Name: orders orders_vehicleid_fkey; Type: FK CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.orders
    ADD CONSTRAINT orders_vehicleid_fkey FOREIGN KEY (vehicleid) REFERENCES kotov_aa.vehicles(vehicleid);


-- Completed on 2026-06-26 11:39:12

--
-- PostgreSQL database dump complete
--

\unrestrict snKl38QtDmlHlRoIN2iZzdVPz9xDRgE3UIfqr4EV2SJVkb86T38fRWHnv2bex5t
--
-- PostgreSQL database dump
--

\restrict 2QIJ5CyUIKe4rrlzpbsWHHZR1UblmcXDHeedRvyd5Vkzrp1YLimEFMf7gMzWv9e

-- Dumped from database version 18.0
-- Dumped by pg_dump version 18.0

-- Started on 2026-06-26 11:40:17

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 819 (class 1259 OID 452142)
-- Name: routes; Type: TABLE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE TABLE kotov_aa.routes (
    routeid integer NOT NULL,
    distance numeric(10,2) NOT NULL,
    fromcityid integer NOT NULL,
    tocityid integer NOT NULL,
    CONSTRAINT chk_cities_different CHECK ((fromcityid <> tocityid)),
    CONSTRAINT routes_distance_check CHECK ((distance > (0)::numeric))
);


ALTER TABLE kotov_aa.routes OWNER TO kotov_aa;

--
-- TOC entry 818 (class 1259 OID 452141)
-- Name: routes_routeid_seq; Type: SEQUENCE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE SEQUENCE kotov_aa.routes_routeid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE kotov_aa.routes_routeid_seq OWNER TO kotov_aa;

--
-- TOC entry 6568 (class 0 OID 0)
-- Dependencies: 818
-- Name: routes_routeid_seq; Type: SEQUENCE OWNED BY; Schema: kotov_aa; Owner: kotov_aa
--

ALTER SEQUENCE kotov_aa.routes_routeid_seq OWNED BY kotov_aa.routes.routeid;


--
-- TOC entry 6309 (class 2604 OID 452145)
-- Name: routes routeid; Type: DEFAULT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.routes ALTER COLUMN routeid SET DEFAULT nextval('kotov_aa.routes_routeid_seq'::regclass);


--
-- TOC entry 6562 (class 0 OID 452142)
-- Dependencies: 819
-- Data for Name: routes; Type: TABLE DATA; Schema: kotov_aa; Owner: kotov_aa
--

INSERT INTO kotov_aa.routes VALUES (1, 410.20, 1, 2);
INSERT INTO kotov_aa.routes VALUES (2, 680.50, 2, 3);
INSERT INTO kotov_aa.routes VALUES (3, 1120.00, 3, 4);
INSERT INTO kotov_aa.routes VALUES (4, 2950.00, 4, 5);
INSERT INTO kotov_aa.routes VALUES (5, 3100.00, 5, 6);
INSERT INTO kotov_aa.routes VALUES (6, 1890.00, 6, 1);


--
-- TOC entry 6569 (class 0 OID 0)
-- Dependencies: 818
-- Name: routes_routeid_seq; Type: SEQUENCE SET; Schema: kotov_aa; Owner: kotov_aa
--

SELECT pg_catalog.setval('kotov_aa.routes_routeid_seq', 6, true);


--
-- TOC entry 6313 (class 2606 OID 452153)
-- Name: routes routes_pkey; Type: CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.routes
    ADD CONSTRAINT routes_pkey PRIMARY KEY (routeid);


--
-- TOC entry 6314 (class 2606 OID 452154)
-- Name: routes routes_fromcityid_fkey; Type: FK CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.routes
    ADD CONSTRAINT routes_fromcityid_fkey FOREIGN KEY (fromcityid) REFERENCES kotov_aa.cities(cityid);


--
-- TOC entry 6315 (class 2606 OID 452159)
-- Name: routes routes_tocityid_fkey; Type: FK CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.routes
    ADD CONSTRAINT routes_tocityid_fkey FOREIGN KEY (tocityid) REFERENCES kotov_aa.cities(cityid);


-- Completed on 2026-06-26 11:40:28

--
-- PostgreSQL database dump complete
--

\unrestrict 2QIJ5CyUIKe4rrlzpbsWHHZR1UblmcXDHeedRvyd5Vkzrp1YLimEFMf7gMzWv9e
--
-- PostgreSQL database dump
--

\restrict rx36bOzzTppukIZiOCLVk1yTe2Gdi1iZ3jXXHFs4GpFx2xFwXHlIaaV2K82ibVr

-- Dumped from database version 18.0
-- Dumped by pg_dump version 18.0

-- Started on 2026-06-26 11:41:19

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 825 (class 1259 OID 452215)
-- Name: users; Type: TABLE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE TABLE kotov_aa.users (
    id integer NOT NULL,
    username character varying(50) NOT NULL,
    password_hash character varying(255) NOT NULL,
    role character varying(20) NOT NULL,
    CONSTRAINT users_role_check CHECK (((role)::text = ANY ((ARRAY['admin'::character varying, 'dispatcher'::character varying, 'driver'::character varying])::text[])))
);


ALTER TABLE kotov_aa.users OWNER TO kotov_aa;

--
-- TOC entry 824 (class 1259 OID 452214)
-- Name: users_id_seq; Type: SEQUENCE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE SEQUENCE kotov_aa.users_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE kotov_aa.users_id_seq OWNER TO kotov_aa;

--
-- TOC entry 6567 (class 0 OID 0)
-- Dependencies: 824
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: kotov_aa; Owner: kotov_aa
--

ALTER SEQUENCE kotov_aa.users_id_seq OWNED BY kotov_aa.users.id;


--
-- TOC entry 6309 (class 2604 OID 452218)
-- Name: users id; Type: DEFAULT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.users ALTER COLUMN id SET DEFAULT nextval('kotov_aa.users_id_seq'::regclass);


--
-- TOC entry 6561 (class 0 OID 452215)
-- Dependencies: 825
-- Data for Name: users; Type: TABLE DATA; Schema: kotov_aa; Owner: kotov_aa
--

INSERT INTO kotov_aa.users VALUES (1, 'admin', 'kFJqeJo2MTBwqBgKnaQ55A==:9PfJwE1gt0/h1V7kxFr0MbsTFSVQsrtJJoeaHooY9t8=', 'admin');
INSERT INTO kotov_aa.users VALUES (2, 'disp_kov', 'fcn8qhEexGgT7o7nBe4H3g==:nybuvbxmB7M0M+ZFjd5/p1RXVGaPlVKpAWeb4odRA58=', 'dispatcher');
INSERT INTO kotov_aa.users VALUES (3, 'drv_sav', 'tx/i4YNEIqL9HnXhNap8QA==:ING6gpJF4vaphrzx9xuz+mJkxlTKCXtC6n0elD8I4+k=', 'driver');


--
-- TOC entry 6568 (class 0 OID 0)
-- Dependencies: 824
-- Name: users_id_seq; Type: SEQUENCE SET; Schema: kotov_aa; Owner: kotov_aa
--

SELECT pg_catalog.setval('kotov_aa.users_id_seq', 3, true);


--
-- TOC entry 6312 (class 2606 OID 452225)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- TOC entry 6314 (class 2606 OID 452227)
-- Name: users users_username_key; Type: CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.users
    ADD CONSTRAINT users_username_key UNIQUE (username);


-- Completed on 2026-06-26 11:41:32

--
-- PostgreSQL database dump complete
--

\unrestrict rx36bOzzTppukIZiOCLVk1yTe2Gdi1iZ3jXXHFs4GpFx2xFwXHlIaaV2K82ibVr
--
-- PostgreSQL database dump
--

\restrict MZg6gtGraQoiAYFapj0wml3V1P4Ws7g8Vgc7ddjuJ96YozaSpW7cfWsAES8diEW

-- Dumped from database version 18.0
-- Dumped by pg_dump version 18.0

-- Started on 2026-06-26 11:42:23

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 821 (class 1259 OID 452165)
-- Name: vehicles; Type: TABLE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE TABLE kotov_aa.vehicles (
    vehicleid integer NOT NULL,
    brand character varying(50) NOT NULL,
    bodytype character varying(30),
    color character varying(30),
    driverid integer
);


ALTER TABLE kotov_aa.vehicles OWNER TO kotov_aa;

--
-- TOC entry 820 (class 1259 OID 452164)
-- Name: vehicles_vehicleid_seq; Type: SEQUENCE; Schema: kotov_aa; Owner: kotov_aa
--

CREATE SEQUENCE kotov_aa.vehicles_vehicleid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE kotov_aa.vehicles_vehicleid_seq OWNER TO kotov_aa;

--
-- TOC entry 6565 (class 0 OID 0)
-- Dependencies: 820
-- Name: vehicles_vehicleid_seq; Type: SEQUENCE OWNED BY; Schema: kotov_aa; Owner: kotov_aa
--

ALTER SEQUENCE kotov_aa.vehicles_vehicleid_seq OWNED BY kotov_aa.vehicles.vehicleid;


--
-- TOC entry 6309 (class 2604 OID 452168)
-- Name: vehicles vehicleid; Type: DEFAULT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.vehicles ALTER COLUMN vehicleid SET DEFAULT nextval('kotov_aa.vehicles_vehicleid_seq'::regclass);


--
-- TOC entry 6559 (class 0 OID 452165)
-- Dependencies: 821
-- Data for Name: vehicles; Type: TABLE DATA; Schema: kotov_aa; Owner: kotov_aa
--

INSERT INTO kotov_aa.vehicles VALUES (1, 'MAN TGS', 'Тент', 'Белый', 1);
INSERT INTO kotov_aa.vehicles VALUES (2, 'КАМАЗ 5490', 'Бортовой', 'Синий', 2);
INSERT INTO kotov_aa.vehicles VALUES (3, 'Volvo FH16', 'Рефрижератор', 'Красный', 3);
INSERT INTO kotov_aa.vehicles VALUES (4, 'ГАЗель NEXT', 'Фургон', 'Серый', 4);
INSERT INTO kotov_aa.vehicles VALUES (5, 'Scania R450', 'Тент', 'Зелёный', 5);
INSERT INTO kotov_aa.vehicles VALUES (6, 'Iveco Daily', 'Изотерм', 'Жёлтый', 6);


--
-- TOC entry 6566 (class 0 OID 0)
-- Dependencies: 820
-- Name: vehicles_vehicleid_seq; Type: SEQUENCE SET; Schema: kotov_aa; Owner: kotov_aa
--

SELECT pg_catalog.setval('kotov_aa.vehicles_vehicleid_seq', 6, true);


--
-- TOC entry 6311 (class 2606 OID 452172)
-- Name: vehicles vehicles_pkey; Type: CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.vehicles
    ADD CONSTRAINT vehicles_pkey PRIMARY KEY (vehicleid);


--
-- TOC entry 6312 (class 2606 OID 452173)
-- Name: vehicles vehicles_driverid_fkey; Type: FK CONSTRAINT; Schema: kotov_aa; Owner: kotov_aa
--

ALTER TABLE ONLY kotov_aa.vehicles
    ADD CONSTRAINT vehicles_driverid_fkey FOREIGN KEY (driverid) REFERENCES kotov_aa.drivers(driverid) ON DELETE SET NULL;


-- Completed on 2026-06-26 11:42:32

--
-- PostgreSQL database dump complete
--

\unrestrict MZg6gtGraQoiAYFapj0wml3V1P4Ws7g8Vgc7ddjuJ96YozaSpW7cfWsAES8diEW
