--
-- PostgreSQL database dump
--

-- Dumped from database version 16.4 (Debian 16.4-1.pgdg120+1)
-- Dumped by pg_dump version 17.2

-- Started on 2025-03-25 12:04:12

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;

--
-- TOC entry 4 (class 2615 OID 2200)
-- Name: public; Type: SCHEMA; Schema: -; Owner: pg_database_owner
--

CREATE SCHEMA public;


ALTER SCHEMA public OWNER TO pg_database_owner;

--
-- TOC entry 3438 (class 0 OID 0)
-- Dependencies: 4
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: pg_database_owner
--

COMMENT ON SCHEMA public IS 'standard public schema';


SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 220 (class 1259 OID 18133)
-- Name: material_type; Type: TABLE; Schema: public; Owner: user20
--

CREATE TABLE public.material_type (
    id integer NOT NULL,
    name character varying NOT NULL,
    defect_rate real DEFAULT 0 NOT NULL
);


ALTER TABLE public.material_type OWNER TO user20;

--
-- TOC entry 219 (class 1259 OID 18132)
-- Name: material_type_id_seq; Type: SEQUENCE; Schema: public; Owner: user20
--

ALTER TABLE public.material_type ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.material_type_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 228 (class 1259 OID 18204)
-- Name: materials; Type: TABLE; Schema: public; Owner: user20
--

CREATE TABLE public.materials (
    id integer NOT NULL,
    name character varying NOT NULL,
    type integer NOT NULL,
    amount_per_package integer NOT NULL,
    measure_unit character varying NOT NULL,
    cost real NOT NULL,
    storage_amount integer DEFAULT 0 NOT NULL,
    min_amount integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.materials OWNER TO user20;

--
-- TOC entry 227 (class 1259 OID 18203)
-- Name: materials_id_seq; Type: SEQUENCE; Schema: public; Owner: user20
--

ALTER TABLE public.materials ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.materials_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 225 (class 1259 OID 18183)
-- Name: partner_products; Type: TABLE; Schema: public; Owner: user20
--

CREATE TABLE public.partner_products (
    id integer NOT NULL,
    product integer NOT NULL,
    partner integer NOT NULL,
    amount integer DEFAULT 0 NOT NULL,
    sell_date date
);


ALTER TABLE public.partner_products OWNER TO user20;

--
-- TOC entry 226 (class 1259 OID 18186)
-- Name: partner_products_id_seq; Type: SEQUENCE; Schema: public; Owner: user20
--

ALTER TABLE public.partner_products ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.partner_products_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 217 (class 1259 OID 18119)
-- Name: partner_type; Type: TABLE; Schema: public; Owner: user20
--

CREATE TABLE public.partner_type (
    id integer NOT NULL,
    name character varying NOT NULL
);


ALTER TABLE public.partner_type OWNER TO user20;

--
-- TOC entry 218 (class 1259 OID 18122)
-- Name: partner_type_id_seq; Type: SEQUENCE; Schema: public; Owner: user20
--

ALTER TABLE public.partner_type ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.partner_type_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 221 (class 1259 OID 18153)
-- Name: partners; Type: TABLE; Schema: public; Owner: user20
--

CREATE TABLE public.partners (
    id integer NOT NULL,
    name character varying NOT NULL,
    director character varying NOT NULL,
    email character varying,
    phone character varying,
    address character varying,
    inn character varying,
    rating smallint DEFAULT 0 NOT NULL,
    type integer NOT NULL
);


ALTER TABLE public.partners OWNER TO user20;

--
-- TOC entry 222 (class 1259 OID 18156)
-- Name: partners_id_seq; Type: SEQUENCE; Schema: public; Owner: user20
--

ALTER TABLE public.partners ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.partners_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 216 (class 1259 OID 18109)
-- Name: product_type; Type: TABLE; Schema: public; Owner: user20
--

CREATE TABLE public.product_type (
    id integer NOT NULL,
    name character varying NOT NULL,
    k real DEFAULT 0 NOT NULL
);


ALTER TABLE public.product_type OWNER TO user20;

--
-- TOC entry 215 (class 1259 OID 18108)
-- Name: product_type_id_seq; Type: SEQUENCE; Schema: public; Owner: user20
--

ALTER TABLE public.product_type ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.product_type_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 224 (class 1259 OID 18171)
-- Name: products; Type: TABLE; Schema: public; Owner: user20
--

CREATE TABLE public.products (
    id integer NOT NULL,
    type integer NOT NULL,
    name character varying NOT NULL,
    articul character varying NOT NULL,
    min_cost real NOT NULL
);


ALTER TABLE public.products OWNER TO user20;

--
-- TOC entry 223 (class 1259 OID 18170)
-- Name: products_id_seq; Type: SEQUENCE; Schema: public; Owner: user20
--

ALTER TABLE public.products ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.products_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 230 (class 1259 OID 18221)
-- Name: products_min_cost_history; Type: TABLE; Schema: public; Owner: user20
--

CREATE TABLE public.products_min_cost_history (
    id integer NOT NULL,
    date timestamp without time zone NOT NULL,
    min_cost integer NOT NULL,
    product integer NOT NULL
);


ALTER TABLE public.products_min_cost_history OWNER TO user20;

--
-- TOC entry 229 (class 1259 OID 18220)
-- Name: products_min_cost_history_id_seq; Type: SEQUENCE; Schema: public; Owner: user20
--

ALTER TABLE public.products_min_cost_history ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.products_min_cost_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 3422 (class 0 OID 18133)
-- Dependencies: 220
-- Data for Name: material_type; Type: TABLE DATA; Schema: public; Owner: user20
--

INSERT INTO public.material_type VALUES (1, 'Тип материала 1', 0.001);
INSERT INTO public.material_type VALUES (2, 'Тип материала 2', 0.0095);
INSERT INTO public.material_type VALUES (3, 'Тип материала 3', 0.0028);
INSERT INTO public.material_type VALUES (4, 'Тип материала 4', 0.0055);
INSERT INTO public.material_type VALUES (5, 'Тип материала 5', 0.0034);


--
-- TOC entry 3430 (class 0 OID 18204)
-- Dependencies: 228
-- Data for Name: materials; Type: TABLE DATA; Schema: public; Owner: user20
--



--
-- TOC entry 3427 (class 0 OID 18183)
-- Dependencies: 225
-- Data for Name: partner_products; Type: TABLE DATA; Schema: public; Owner: user20
--

INSERT INTO public.partner_products VALUES (1, 1, 1, 15500, '2023-03-23');
INSERT INTO public.partner_products VALUES (2, 3, 1, 12350, '2023-12-18');
INSERT INTO public.partner_products VALUES (3, 4, 1, 37400, '2024-06-07');
INSERT INTO public.partner_products VALUES (4, 2, 2, 35000, '2022-12-02');
INSERT INTO public.partner_products VALUES (5, 5, 2, 1250, '2023-05-17');
INSERT INTO public.partner_products VALUES (6, 3, 2, 1000, '2024-06-07');
INSERT INTO public.partner_products VALUES (7, 1, 2, 7550, '2024-07-01');
INSERT INTO public.partner_products VALUES (8, 1, 3, 7250, '2023-01-22');
INSERT INTO public.partner_products VALUES (9, 2, 3, 2500, '2024-07-05');
INSERT INTO public.partner_products VALUES (10, 4, 4, 59050, '2023-03-20');
INSERT INTO public.partner_products VALUES (11, 3, 4, 37200, '2024-03-12');
INSERT INTO public.partner_products VALUES (12, 5, 4, 4500, '2024-05-14');
INSERT INTO public.partner_products VALUES (13, 3, 5, 50000, '2023-09-19');
INSERT INTO public.partner_products VALUES (14, 4, 5, 670000, '2023-11-10');
INSERT INTO public.partner_products VALUES (15, 1, 5, 35000, '2024-04-15');
INSERT INTO public.partner_products VALUES (16, 2, 5, 25000, '2024-06-12');


--
-- TOC entry 3419 (class 0 OID 18119)
-- Dependencies: 217
-- Data for Name: partner_type; Type: TABLE DATA; Schema: public; Owner: user20
--

INSERT INTO public.partner_type VALUES (1, 'ЗАО');
INSERT INTO public.partner_type VALUES (2, 'ООО');
INSERT INTO public.partner_type VALUES (3, 'ПАО');
INSERT INTO public.partner_type VALUES (4, 'ОАО');


--
-- TOC entry 3423 (class 0 OID 18153)
-- Dependencies: 221
-- Data for Name: partners; Type: TABLE DATA; Schema: public; Owner: user20
--

INSERT INTO public.partners VALUES (1, 'База Строитель', 'Иванова Александра Ивановна', 'aleksandraivanova@ml.ru', '493 123 45 67', '652050, Кемеровская область, город Юрга, ул. Лесная, 15', '2222455179', 7, 1);
INSERT INTO public.partners VALUES (2, 'Паркет 29', 'Петров Василий Петрович', 'vppetrov@vl.ru', '987 123 56 78', '164500, Архангельская область, город Северодвинск, ул. Строителей, 18', '3333888520', 7, 2);
INSERT INTO public.partners VALUES (3, 'Стройсервис', 'Соловьев Андрей Николаевич', 'ansolovev@st.ru', '812 223 32 00', '188910, Ленинградская область, город Приморск, ул. Парковая, 21', '4440391035', 7, 3);
INSERT INTO public.partners VALUES (4, 'Ремонт и отделка', 'Воробьева Екатерина Валерьевна', 'ekaterina.vorobeva@ml.ru', '444 222 33 11', '143960, Московская область, город Реутов, ул. Свободы, 51', '1111520857', 5, 4);
INSERT INTO public.partners VALUES (5, 'МонтажПро', 'Степанов Степан Сергеевич', 'stepanov@stepan.ru', '912 888 33 33', '309500, Белгородская область, город Старый Оскол, ул. Рабочая, 122', '5552431140', 10, 1);


--
-- TOC entry 3418 (class 0 OID 18109)
-- Dependencies: 216
-- Data for Name: product_type; Type: TABLE DATA; Schema: public; Owner: user20
--

INSERT INTO public.product_type VALUES (1, 'Ламинат', 2.35);
INSERT INTO public.product_type VALUES (2, 'Массивная доска', 5.15);
INSERT INTO public.product_type VALUES (3, 'Паркетная доска', 4.34);
INSERT INTO public.product_type VALUES (4, 'Пробковое покрытие', 1.5);


--
-- TOC entry 3426 (class 0 OID 18171)
-- Dependencies: 224
-- Data for Name: products; Type: TABLE DATA; Schema: public; Owner: user20
--

INSERT INTO public.products VALUES (1, 3, 'Паркетная доска Ясень темный однополосная 14 мм', '8758385', 4456.9);
INSERT INTO public.products VALUES (2, 3, 'Инженерная доска Дуб Французская елка однополосная 12 мм', '8858958', 7330.99);
INSERT INTO public.products VALUES (3, 1, 'Ламинат Дуб дымчато-белый 33 класс 12 мм', '7750282', 1799.33);
INSERT INTO public.products VALUES (4, 1, 'Ламинат Дуб серый 32 класс 8 мм с фаской', '7028748', 3890.41);
INSERT INTO public.products VALUES (5, 4, 'Пробковое напольное клеевое покрытие 32 класс 4 мм', '5012543', 5450.59);


--
-- TOC entry 3432 (class 0 OID 18221)
-- Dependencies: 230
-- Data for Name: products_min_cost_history; Type: TABLE DATA; Schema: public; Owner: user20
--



--
-- TOC entry 3439 (class 0 OID 0)
-- Dependencies: 219
-- Name: material_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: user20
--

SELECT pg_catalog.setval('public.material_type_id_seq', 10, true);


--
-- TOC entry 3440 (class 0 OID 0)
-- Dependencies: 227
-- Name: materials_id_seq; Type: SEQUENCE SET; Schema: public; Owner: user20
--

SELECT pg_catalog.setval('public.materials_id_seq', 1, false);


--
-- TOC entry 3441 (class 0 OID 0)
-- Dependencies: 226
-- Name: partner_products_id_seq; Type: SEQUENCE SET; Schema: public; Owner: user20
--

SELECT pg_catalog.setval('public.partner_products_id_seq', 16, true);


--
-- TOC entry 3442 (class 0 OID 0)
-- Dependencies: 218
-- Name: partner_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: user20
--

SELECT pg_catalog.setval('public.partner_type_id_seq', 4, true);


--
-- TOC entry 3443 (class 0 OID 0)
-- Dependencies: 222
-- Name: partners_id_seq; Type: SEQUENCE SET; Schema: public; Owner: user20
--

SELECT pg_catalog.setval('public.partners_id_seq', 5, true);


--
-- TOC entry 3444 (class 0 OID 0)
-- Dependencies: 215
-- Name: product_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: user20
--

SELECT pg_catalog.setval('public.product_type_id_seq', 4, true);


--
-- TOC entry 3445 (class 0 OID 0)
-- Dependencies: 223
-- Name: products_id_seq; Type: SEQUENCE SET; Schema: public; Owner: user20
--

SELECT pg_catalog.setval('public.products_id_seq', 5, true);


--
-- TOC entry 3446 (class 0 OID 0)
-- Dependencies: 229
-- Name: products_min_cost_history_id_seq; Type: SEQUENCE SET; Schema: public; Owner: user20
--

SELECT pg_catalog.setval('public.products_min_cost_history_id_seq', 1, false);


--
-- TOC entry 3253 (class 2606 OID 18140)
-- Name: material_type material_type_pk; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.material_type
    ADD CONSTRAINT material_type_pk PRIMARY KEY (id);


--
-- TOC entry 3255 (class 2606 OID 18142)
-- Name: material_type material_type_unique; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.material_type
    ADD CONSTRAINT material_type_unique UNIQUE (name);


--
-- TOC entry 3263 (class 2606 OID 18212)
-- Name: materials materials_pk; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.materials
    ADD CONSTRAINT materials_pk PRIMARY KEY (id);


--
-- TOC entry 3265 (class 2606 OID 18214)
-- Name: materials materials_unique; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.materials
    ADD CONSTRAINT materials_unique UNIQUE (name);


--
-- TOC entry 3261 (class 2606 OID 18191)
-- Name: partner_products partner_products_pk; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.partner_products
    ADD CONSTRAINT partner_products_pk PRIMARY KEY (id);


--
-- TOC entry 3249 (class 2606 OID 18127)
-- Name: partner_type partner_type_pk; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.partner_type
    ADD CONSTRAINT partner_type_pk PRIMARY KEY (id);


--
-- TOC entry 3251 (class 2606 OID 18131)
-- Name: partner_type partner_type_unique; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.partner_type
    ADD CONSTRAINT partner_type_unique UNIQUE (name);


--
-- TOC entry 3257 (class 2606 OID 18161)
-- Name: partners partners_pk; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.partners
    ADD CONSTRAINT partners_pk PRIMARY KEY (id);


--
-- TOC entry 3245 (class 2606 OID 18116)
-- Name: product_type product_type_pk; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.product_type
    ADD CONSTRAINT product_type_pk PRIMARY KEY (id);


--
-- TOC entry 3247 (class 2606 OID 18118)
-- Name: product_type product_type_unique; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.product_type
    ADD CONSTRAINT product_type_unique UNIQUE (name);


--
-- TOC entry 3267 (class 2606 OID 18225)
-- Name: products_min_cost_history products_min_cost_history_pk; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.products_min_cost_history
    ADD CONSTRAINT products_min_cost_history_pk PRIMARY KEY (id);


--
-- TOC entry 3259 (class 2606 OID 18177)
-- Name: products products_pk; Type: CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.products
    ADD CONSTRAINT products_pk PRIMARY KEY (id);


--
-- TOC entry 3272 (class 2606 OID 18215)
-- Name: materials materials_material_type_fk; Type: FK CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.materials
    ADD CONSTRAINT materials_material_type_fk FOREIGN KEY (type) REFERENCES public.material_type(id);


--
-- TOC entry 3270 (class 2606 OID 18193)
-- Name: partner_products partner_products_partners_fk; Type: FK CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.partner_products
    ADD CONSTRAINT partner_products_partners_fk FOREIGN KEY (partner) REFERENCES public.partners(id);


--
-- TOC entry 3271 (class 2606 OID 18198)
-- Name: partner_products partner_products_products_fk; Type: FK CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.partner_products
    ADD CONSTRAINT partner_products_products_fk FOREIGN KEY (product) REFERENCES public.products(id);


--
-- TOC entry 3268 (class 2606 OID 18165)
-- Name: partners partners_partner_type_fk; Type: FK CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.partners
    ADD CONSTRAINT partners_partner_type_fk FOREIGN KEY (type) REFERENCES public.partner_type(id);


--
-- TOC entry 3273 (class 2606 OID 18226)
-- Name: products_min_cost_history products_min_cost_history_products_fk; Type: FK CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.products_min_cost_history
    ADD CONSTRAINT products_min_cost_history_products_fk FOREIGN KEY (product) REFERENCES public.products(id);


--
-- TOC entry 3269 (class 2606 OID 18178)
-- Name: products products_product_type_fk; Type: FK CONSTRAINT; Schema: public; Owner: user20
--

ALTER TABLE ONLY public.products
    ADD CONSTRAINT products_product_type_fk FOREIGN KEY (type) REFERENCES public.product_type(id);


-- Completed on 2025-03-25 12:04:15

--
-- PostgreSQL database dump complete
--

