--
--


-- Started on 2025-11-06 22:54:05

SELECT pg_catalog.set_config('search_path', '', false);

DROP DATABASE mega_build;
--
-- TOC entry 4983 (class 1262 OID 24937)
-- Name: mega_build; Type: DATABASE; Schema: -; Owner: postgres
--

CREATE DATABASE mega_build WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'Russian_Russia.1251';


ALTER DATABASE mega_build OWNER TO postgres;

connect mega_build

SELECT pg_catalog.set_config('search_path', '', false);

--
-- TOC entry 873 (class 1247 OID 25010)
-- Name: resource_type_enum; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE public.resource_type_enum AS ENUM (
    'MEHNAT',
    'TEXNIKA',
    'MATERIAL'
);


ALTER TYPE public.resource_type_enum OWNER TO postgres;

--
-- TOC entry 239 (class 1255 OID 25153)
-- Name: trg_set_updated_at(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.trg_set_updated_at() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
begin
  new.updated_at = now();
  return new;
end; $$;


ALTER FUNCTION public.trg_set_updated_at() OWNER TO postgres;



--
-- TOC entry 216 (class 1259 OID 24939)
-- Name: customers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.customers (
    id bigint NOT NULL,
    name text NOT NULL,
    inn character varying(32),
    phone character varying(50),
    address text,
    status character varying(16) DEFAULT 'active'::character varying NOT NULL,
    notes text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT kontragent_status_check CHECK (((status)::text = ANY ((ARRAY['active'::character varying, 'inactive'::character varying])::text[])))
);


ALTER TABLE public.customers OWNER TO postgres;

--
-- TOC entry 215 (class 1259 OID 24938)
-- Name: kontragent_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.kontragent_id_seq OWNER TO postgres;

--
-- TOC entry 4984 (class 0 OID 0)
-- Dependencies: 215
-- Name: kontragent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.kontragent_id_seq OWNED BY public.customers.id;


--
-- TOC entry 238 (class 1259 OID 25180)
-- Name: object_members; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.object_members (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    object_id bigint NOT NULL,
    role_key character varying(64) NOT NULL,
    assigned_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.object_members OWNER TO postgres;

--
-- TOC entry 237 (class 1259 OID 25179)
-- Name: object_members_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.object_members_id_seq OWNER TO postgres;

--
-- TOC entry 4985 (class 0 OID 0)
-- Dependencies: 237
-- Name: object_members_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.object_members_id_seq OWNED BY public.object_members.id;


--
-- TOC entry 222 (class 1259 OID 24993)
-- Name: object_parts; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.object_parts (
    id bigint NOT NULL,
    object_id bigint NOT NULL,
    name character varying(255) NOT NULL,
    status character varying(16) DEFAULT 'planned'::character varying NOT NULL,
    start_date date,
    end_date date,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT object_parts_status_check CHECK (((status)::text = ANY ((ARRAY['planned'::character varying, 'active'::character varying, 'done'::character varying, 'closed'::character varying])::text[])))
);


ALTER TABLE public.object_parts OWNER TO postgres;

--
-- TOC entry 221 (class 1259 OID 24992)
-- Name: object_parts_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.object_parts_id_seq OWNER TO postgres;

--
-- TOC entry 4986 (class 0 OID 0)
-- Dependencies: 221
-- Name: object_parts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.object_parts_id_seq OWNED BY public.object_parts.id;


--
-- TOC entry 220 (class 1259 OID 24976)
-- Name: objects; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.objects (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    name character varying(255) NOT NULL,
    start_date date,
    end_date date,
    status character varying(16) DEFAULT 'planned'::character varying NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT chk_objects_status CHECK (((status)::text = ANY ((ARRAY['planned'::character varying, 'active'::character varying, 'on_hold'::character varying, 'closed'::character varying])::text[])))
);


ALTER TABLE public.objects OWNER TO postgres;

--
-- TOC entry 219 (class 1259 OID 24975)
-- Name: objects_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.objects_id_seq OWNER TO postgres;

--
-- TOC entry 4987 (class 0 OID 0)
-- Dependencies: 219
-- Name: objects_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.objects_id_seq OWNED BY public.objects.id;


--
-- TOC entry 218 (class 1259 OID 24955)
-- Name: projects; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.projects (
    id bigint NOT NULL,
    name character varying(255) NOT NULL,
    customer_id bigint NOT NULL,
    address text,
    start_date date,
    end_date date,
    status character varying(16) DEFAULT 'planned'::character varying NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT projects_status_check CHECK (((status)::text = ANY ((ARRAY['planned'::character varying, 'active'::character varying, 'on_hold'::character varying, 'closed'::character varying])::text[])))
);


ALTER TABLE public.projects OWNER TO postgres;

--
-- TOC entry 217 (class 1259 OID 24954)
-- Name: projects_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.projects_id_seq OWNER TO postgres;

--
-- TOC entry 4988 (class 0 OID 0)
-- Dependencies: 217
-- Name: projects_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.projects_id_seq OWNED BY public.projects.id;


--
-- TOC entry 226 (class 1259 OID 25029)
-- Name: resource_catalog; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.resource_catalog (
    id bigint NOT NULL,
    code text NOT NULL,
    name text NOT NULL,
    name_sku text,
    resource_type public.resource_type_enum NOT NULL,
    unit_id bigint NOT NULL,
    description text,
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.resource_catalog OWNER TO postgres;

--
-- TOC entry 225 (class 1259 OID 25028)
-- Name: resource_catalog_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.resource_catalog_id_seq OWNER TO postgres;

--
-- TOC entry 4989 (class 0 OID 0)
-- Dependencies: 225
-- Name: resource_catalog_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.resource_catalog_id_seq OWNED BY public.resource_catalog.id;


--
-- TOC entry 224 (class 1259 OID 25018)
-- Name: units; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.units (
    id bigint NOT NULL,
    name text NOT NULL
);


ALTER TABLE public.units OWNER TO postgres;

--
-- TOC entry 223 (class 1259 OID 25017)
-- Name: units_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.units_id_seq OWNER TO postgres;

--
-- TOC entry 4990 (class 0 OID 0)
-- Dependencies: 223
-- Name: units_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.units_id_seq OWNED BY public.units.id;


--
-- TOC entry 236 (class 1259 OID 25163)
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.users (
    id bigint NOT NULL,
    username character varying(64) NOT NULL,
    full_name character varying(255) NOT NULL,
    phone character varying(32),
    email character varying(128),
    password_hash character varying(255) NOT NULL,
    auth_key character varying(32) NOT NULL,
    role_key character varying(64) DEFAULT 'user'::character varying NOT NULL,
    status smallint DEFAULT 10 NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.users OWNER TO postgres;

--
-- TOC entry 235 (class 1259 OID 25162)
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.users_id_seq OWNER TO postgres;

--
-- TOC entry 4991 (class 0 OID 0)
-- Dependencies: 235
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

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


--
-- TOC entry 234 (class 1259 OID 25129)
-- Name: work_categories; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.work_categories (
    id bigint NOT NULL,
    code character varying(32) NOT NULL,
    name_uz character varying(255) NOT NULL,
    name_ru character varying(255),
    name_en character varying(255),
    parent_id bigint,
    shnk_code character varying(32),
    description text,
    sort_order integer DEFAULT 100 NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.work_categories OWNER TO postgres;

--
-- TOC entry 233 (class 1259 OID 25128)
-- Name: work_categories_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.work_categories_id_seq OWNER TO postgres;

--
-- TOC entry 4992 (class 0 OID 0)
-- Dependencies: 233
-- Name: work_categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.work_categories_id_seq OWNED BY public.work_categories.id;


--
-- TOC entry 230 (class 1259 OID 25075)
-- Name: work_resources; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.work_resources (
    id bigint NOT NULL,
    work_id bigint NOT NULL,
    number text,
    resource_id bigint NOT NULL,
    unit_id bigint,
    norm_work_unit numeric(18,6) NOT NULL,
    qty_total numeric(18,6),
    unit_price numeric(18,2),
    total_price numeric(18,2),
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    object_id bigint,
    code text,
    CONSTRAINT chk_wr_nonneg CHECK (((COALESCE(norm_work_unit, (0)::numeric) >= (0)::numeric) AND (COALESCE(qty_total, (0)::numeric) >= (0)::numeric) AND (COALESCE(unit_price, (0)::numeric) >= (0)::numeric) AND (COALESCE(total_price, (0)::numeric) >= (0)::numeric)))
);


ALTER TABLE public.work_resources OWNER TO postgres;

--
-- TOC entry 229 (class 1259 OID 25074)
-- Name: work_resources_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.work_resources_id_seq OWNER TO postgres;

--
-- TOC entry 4993 (class 0 OID 0)
-- Dependencies: 229
-- Name: work_resources_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.work_resources_id_seq OWNED BY public.work_resources.id;


--
-- TOC entry 232 (class 1259 OID 25107)
-- Name: work_schedules; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.work_schedules (
    id bigint NOT NULL,
    work_id bigint NOT NULL,
    planned_start date NOT NULL,
    planned_end date NOT NULL,
    planned_days integer GENERATED ALWAYS AS (((planned_end - planned_start) + 1)) STORED,
    fact_start date,
    fact_end date,
    fact_days integer GENERATED ALWAYS AS (
CASE
    WHEN ((fact_start IS NOT NULL) AND (fact_end IS NOT NULL)) THEN ((fact_end - fact_start) + 1)
    ELSE NULL::integer
END) STORED,
    done_percent numeric(5,2) DEFAULT 0,
    done_quantity numeric(18,3),
    status character varying(16) DEFAULT 'planned'::character varying NOT NULL,
    note text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    object_id bigint,
    CONSTRAINT work_schedules_status_check CHECK (((status)::text = ANY ((ARRAY['planned'::character varying, 'active'::character varying, 'done'::character varying, 'closed'::character varying])::text[])))
);


ALTER TABLE public.work_schedules OWNER TO postgres;

--
-- TOC entry 231 (class 1259 OID 25106)
-- Name: work_schedules_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.work_schedules_id_seq OWNER TO postgres;

--
-- TOC entry 4994 (class 0 OID 0)
-- Dependencies: 231
-- Name: work_schedules_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.work_schedules_id_seq OWNED BY public.work_schedules.id;


--
-- TOC entry 228 (class 1259 OID 25052)
-- Name: works; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.works (
    id bigint NOT NULL,
    object_part_id bigint NOT NULL,
    number text NOT NULL,
    code text,
    name text NOT NULL,
    unit_id bigint,
    qty_units numeric(18,4),
    unit_price numeric(18,2),
    total_price numeric(18,2),
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    name_uzbek text,
    work_category_id bigint DEFAULT 1 NOT NULL,
    object_id bigint
);


ALTER TABLE public.works OWNER TO postgres;

--
-- TOC entry 227 (class 1259 OID 25051)
-- Name: works_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.works_id_seq OWNER TO postgres;

--
-- TOC entry 4995 (class 0 OID 0)
-- Dependencies: 227
-- Name: works_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.works_id_seq OWNED BY public.works.id;


--
-- TOC entry 4677 (class 2604 OID 24942)
-- Name: customers id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customers ALTER COLUMN id SET DEFAULT nextval('public.kontragent_id_seq'::regclass);


--
-- TOC entry 4722 (class 2604 OID 25183)
-- Name: object_members id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.object_members ALTER COLUMN id SET DEFAULT nextval('public.object_members_id_seq'::regclass);


--
-- TOC entry 4689 (class 2604 OID 24996)
-- Name: object_parts id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.object_parts ALTER COLUMN id SET DEFAULT nextval('public.object_parts_id_seq'::regclass);


--
-- TOC entry 4685 (class 2604 OID 24979)
-- Name: objects id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.objects ALTER COLUMN id SET DEFAULT nextval('public.objects_id_seq'::regclass);


--
-- TOC entry 4681 (class 2604 OID 24958)
-- Name: projects id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.projects ALTER COLUMN id SET DEFAULT nextval('public.projects_id_seq'::regclass);


--
-- TOC entry 4694 (class 2604 OID 25032)
-- Name: resource_catalog id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.resource_catalog ALTER COLUMN id SET DEFAULT nextval('public.resource_catalog_id_seq'::regclass);


--
-- TOC entry 4693 (class 2604 OID 25021)
-- Name: units id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.units ALTER COLUMN id SET DEFAULT nextval('public.units_id_seq'::regclass);


--
-- TOC entry 4717 (class 2604 OID 25166)
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- TOC entry 4712 (class 2604 OID 25132)
-- Name: work_categories id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_categories ALTER COLUMN id SET DEFAULT nextval('public.work_categories_id_seq'::regclass);


--
-- TOC entry 4702 (class 2604 OID 25078)
-- Name: work_resources id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_resources ALTER COLUMN id SET DEFAULT nextval('public.work_resources_id_seq'::regclass);


--
-- TOC entry 4705 (class 2604 OID 25110)
-- Name: work_schedules id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_schedules ALTER COLUMN id SET DEFAULT nextval('public.work_schedules_id_seq'::regclass);


--
-- TOC entry 4698 (class 2604 OID 25055)
-- Name: works id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.works ALTER COLUMN id SET DEFAULT nextval('public.works_id_seq'::regclass);


--
-- TOC entry 4955 (class 0 OID 24939)
-- Dependencies: 216
-- Data for Name: customers; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.customers (id, name, inn, phone, address, status, notes, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4977 (class 0 OID 25180)
-- Dependencies: 238
-- Data for Name: object_members; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.object_members (id, user_id, object_id, role_key, assigned_at) FROM stdin;
\.


--
-- TOC entry 4961 (class 0 OID 24993)
-- Dependencies: 222
-- Data for Name: object_parts; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.object_parts (id, object_id, name, status, start_date, end_date, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4959 (class 0 OID 24976)
-- Dependencies: 220
-- Data for Name: objects; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.objects (id, project_id, name, start_date, end_date, status, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4957 (class 0 OID 24955)
-- Dependencies: 218
-- Data for Name: projects; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.projects (id, name, customer_id, address, start_date, end_date, status, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4965 (class 0 OID 25029)
-- Dependencies: 226
-- Data for Name: resource_catalog; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.resource_catalog (id, code, name, name_sku, resource_type, unit_id, description, is_active, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4963 (class 0 OID 25018)
-- Dependencies: 224
-- Data for Name: units; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.units (id, name) FROM stdin;
\.


--
-- TOC entry 4975 (class 0 OID 25163)
-- Dependencies: 236
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.users (id, username, full_name, phone, email, password_hash, auth_key, role_key, status, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4973 (class 0 OID 25129)
-- Dependencies: 234
-- Data for Name: work_categories; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.work_categories (id, code, name_uz, name_ru, name_en, parent_id, shnk_code, description, sort_order, is_active, created_at, updated_at) FROM stdin;
1	000	Ish turi ko`rsatilmagan	Вид работ не указан	\N	\N	\N	\N	1	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
2	CAT-PREP	Tayyorgarlik ishlari	Подготовительные работы	\N	\N	\N	\N	10	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
3	CAT-EARTH	Yer ishlari	Земляные работы	\N	\N	\N	\N	20	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
4	CAT-FUND	Poydevor ishlari	Фундаментные работы	\N	\N	\N	\N	30	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
5	CAT-RC-MO	Monolit temirbeton	Монолитные ж/б работы	\N	\N	\N	\N	40	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
6	CAT-MASON	G‘isht/blok terish	Каменные (кирпичная кладка)	\N	\N	\N	\N	50	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
7	CAT-RC-MT	Temirbeton montaj	Монтаж ж/б конструкций	\N	\N	\N	\N	60	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
8	CAT-STEEL	Metall konstruktsiyalar montaji	Монтаж металлических конструкций	\N	\N	\N	\N	70	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
9	CAT-ROOF	Tom ishlari	Кровельные работы	\N	\N	\N	\N	80	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
10	CAT-ENCL	Fasad/deraza/eshik	Ограждающие конструкции, окна/двери	\N	\N	\N	\N	90	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
11	CAT-FININ	Ichki pardoz ishlari	Отделочные работы (внутренние)	\N	\N	\N	\N	100	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
12	CAT-MEP-S	Santexnika	Сантехнические работы	\N	\N	\N	\N	110	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
13	CAT-MEP-E	Elektr montaj	Электромонтажные работы	\N	\N	\N	\N	120	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
14	CAT-FACA	Fasad pardoz	Отделка фасадов	\N	\N	\N	\N	130	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
15	CAT-LANDS	Obodonlashtirish	Благоустройство и озеленение	\N	\N	\N	\N	140	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
16	CAT-DEM	Demontaj	Демонтажные работы	\N	\N	\N	\N	150	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
17	CAT-SPC	Boshqa / maxsus ishlar	Прочие/специальные работы	\N	\N	\N	\N	160	t	2025-10-30 10:14:05.39859+00	2025-10-30 10:14:05.39859+00
\.


--
-- TOC entry 4969 (class 0 OID 25075)
-- Dependencies: 230
-- Data for Name: work_resources; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.work_resources (id, work_id, number, resource_id, unit_id, norm_work_unit, qty_total, unit_price, total_price, created_at, updated_at, object_id, code) FROM stdin;
\.


--
-- TOC entry 4971 (class 0 OID 25107)
-- Dependencies: 232
-- Data for Name: work_schedules; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.work_schedules (id, work_id, planned_start, planned_end, fact_start, fact_end, done_percent, done_quantity, status, note, created_at, updated_at, object_id) FROM stdin;
\.


--
-- TOC entry 4967 (class 0 OID 25052)
-- Dependencies: 228
-- Data for Name: works; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.works (id, object_part_id, number, code, name, unit_id, qty_units, unit_price, total_price, created_at, updated_at, name_uzbek, work_category_id, object_id) FROM stdin;
\.


--
-- TOC entry 4996 (class 0 OID 0)
-- Dependencies: 215
-- Name: kontragent_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 4997 (class 0 OID 0)
-- Dependencies: 237
-- Name: object_members_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 4998 (class 0 OID 0)
-- Dependencies: 221
-- Name: object_parts_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 4999 (class 0 OID 0)
-- Dependencies: 219
-- Name: objects_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 5000 (class 0 OID 0)
-- Dependencies: 217
-- Name: projects_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 5001 (class 0 OID 0)
-- Dependencies: 225
-- Name: resource_catalog_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 5002 (class 0 OID 0)
-- Dependencies: 223
-- Name: units_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 5003 (class 0 OID 0)
-- Dependencies: 235
-- Name: users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 5004 (class 0 OID 0)
-- Dependencies: 233
-- Name: work_categories_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.work_categories_id_seq', 17, true);


--
-- TOC entry 5005 (class 0 OID 0)
-- Dependencies: 229
-- Name: work_resources_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 5006 (class 0 OID 0)
-- Dependencies: 231
-- Name: work_schedules_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 5007 (class 0 OID 0)
-- Dependencies: 227
-- Name: works_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

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


--
-- TOC entry 4732 (class 2606 OID 24952)
-- Name: customers kontragent_inn_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customers
    ADD CONSTRAINT kontragent_inn_key UNIQUE (inn);


--
-- TOC entry 4734 (class 2606 OID 24950)
-- Name: customers kontragent_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customers
    ADD CONSTRAINT kontragent_pkey PRIMARY KEY (id);


--
-- TOC entry 4792 (class 2606 OID 25186)
-- Name: object_members object_members_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.object_members
    ADD CONSTRAINT object_members_pkey PRIMARY KEY (id);


--
-- TOC entry 4794 (class 2606 OID 25188)
-- Name: object_members object_members_user_id_object_id_role_key_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.object_members
    ADD CONSTRAINT object_members_user_id_object_id_role_key_key UNIQUE (user_id, object_id, role_key);


--
-- TOC entry 4745 (class 2606 OID 25002)
-- Name: object_parts object_parts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.object_parts
    ADD CONSTRAINT object_parts_pkey PRIMARY KEY (id);


--
-- TOC entry 4742 (class 2606 OID 24985)
-- Name: objects objects_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.objects
    ADD CONSTRAINT objects_pkey PRIMARY KEY (id);


--
-- TOC entry 4737 (class 2606 OID 24968)
-- Name: projects projects_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.projects
    ADD CONSTRAINT projects_name_key UNIQUE (name);


--
-- TOC entry 4739 (class 2606 OID 24966)
-- Name: projects projects_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.projects
    ADD CONSTRAINT projects_pkey PRIMARY KEY (id);


--
-- TOC entry 4753 (class 2606 OID 25041)
-- Name: resource_catalog resource_catalog_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.resource_catalog
    ADD CONSTRAINT resource_catalog_name_key UNIQUE (name);


--
-- TOC entry 4755 (class 2606 OID 25043)
-- Name: resource_catalog resource_catalog_name_sku_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.resource_catalog
    ADD CONSTRAINT resource_catalog_name_sku_key UNIQUE (name_sku);


--
-- TOC entry 4757 (class 2606 OID 25039)
-- Name: resource_catalog resource_catalog_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.resource_catalog
    ADD CONSTRAINT resource_catalog_pkey PRIMARY KEY (id);


--
-- TOC entry 4747 (class 2606 OID 25027)
-- Name: units units_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.units
    ADD CONSTRAINT units_name_key UNIQUE (name);


--
-- TOC entry 4749 (class 2606 OID 25025)
-- Name: units units_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.units
    ADD CONSTRAINT units_pkey PRIMARY KEY (id);


--
-- TOC entry 4778 (class 2606 OID 25144)
-- Name: work_categories uq_work_cat_parent_name_uz; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_categories
    ADD CONSTRAINT uq_work_cat_parent_name_uz UNIQUE (parent_id, name_uz);


--
-- TOC entry 4786 (class 2606 OID 25174)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

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


--
-- TOC entry 4788 (class 2606 OID 25176)
-- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

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


--
-- TOC entry 4780 (class 2606 OID 25142)
-- Name: work_categories work_categories_code_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_categories
    ADD CONSTRAINT work_categories_code_key UNIQUE (code);


--
-- TOC entry 4782 (class 2606 OID 25140)
-- Name: work_categories work_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_categories
    ADD CONSTRAINT work_categories_pkey PRIMARY KEY (id);


--
-- TOC entry 4769 (class 2606 OID 25085)
-- Name: work_resources work_resources_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_resources
    ADD CONSTRAINT work_resources_pkey PRIMARY KEY (id);


--
-- TOC entry 4773 (class 2606 OID 25121)
-- Name: work_schedules work_schedules_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_schedules
    ADD CONSTRAINT work_schedules_pkey PRIMARY KEY (id);


--
-- TOC entry 4761 (class 2606 OID 25062)
-- Name: works works_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.works
    ADD CONSTRAINT works_pkey PRIMARY KEY (id);


--
-- TOC entry 4763 (class 2606 OID 25105)
-- Name: works works_unique_uzbek; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.works
    ADD CONSTRAINT works_unique_uzbek UNIQUE (name_uzbek);


--
-- TOC entry 4730 (class 1259 OID 24953)
-- Name: ix_kontragent_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_kontragent_name ON public.customers USING btree (lower(name));


--
-- TOC entry 4789 (class 1259 OID 25190)
-- Name: ix_object_members_object; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_object_members_object ON public.object_members USING btree (object_id);


--
-- TOC entry 4790 (class 1259 OID 25189)
-- Name: ix_object_members_user; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_object_members_user ON public.object_members USING btree (user_id);


--
-- TOC entry 4740 (class 1259 OID 24991)
-- Name: ix_objects_project; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_objects_project ON public.objects USING btree (project_id);


--
-- TOC entry 4743 (class 1259 OID 25008)
-- Name: ix_parts_object; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_parts_object ON public.object_parts USING btree (object_id);


--
-- TOC entry 4735 (class 1259 OID 24974)
-- Name: ix_projects_kontragent; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_projects_kontragent ON public.projects USING btree (customer_id);


--
-- TOC entry 4750 (class 1259 OID 25049)
-- Name: ix_resource_catalog_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_resource_catalog_name ON public.resource_catalog USING gin (to_tsvector('simple'::regconfig, name));


--
-- TOC entry 4751 (class 1259 OID 25050)
-- Name: ix_resource_catalog_type; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_resource_catalog_type ON public.resource_catalog USING btree (resource_type);


--
-- TOC entry 4783 (class 1259 OID 25177)
-- Name: ix_users_role; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_users_role ON public.users USING btree (role_key);


--
-- TOC entry 4784 (class 1259 OID 25178)
-- Name: ix_users_status; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_users_status ON public.users USING btree (status);


--
-- TOC entry 4774 (class 1259 OID 25151)
-- Name: ix_work_cat_active; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_work_cat_active ON public.work_categories USING btree (is_active);


--
-- TOC entry 4775 (class 1259 OID 25150)
-- Name: ix_work_cat_parent; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_work_cat_parent ON public.work_categories USING btree (parent_id);


--
-- TOC entry 4776 (class 1259 OID 25152)
-- Name: ix_work_cat_sort; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_work_cat_sort ON public.work_categories USING btree (sort_order);


--
-- TOC entry 4764 (class 1259 OID 25191)
-- Name: ix_work_resources_object; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_work_resources_object ON public.work_resources USING btree (object_id);


--
-- TOC entry 4770 (class 1259 OID 25203)
-- Name: ix_work_schedules_object; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_work_schedules_object ON public.work_schedules USING btree (object_id);


--
-- TOC entry 4758 (class 1259 OID 25209)
-- Name: ix_works_object; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_works_object ON public.works USING btree (object_id);


--
-- TOC entry 4759 (class 1259 OID 25073)
-- Name: ix_works_unit; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_works_unit ON public.works USING btree (unit_id);


--
-- TOC entry 4765 (class 1259 OID 25102)
-- Name: ix_wr_resource; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_wr_resource ON public.work_resources USING btree (resource_id);


--
-- TOC entry 4766 (class 1259 OID 25103)
-- Name: ix_wr_unit; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_wr_unit ON public.work_resources USING btree (unit_id);


--
-- TOC entry 4767 (class 1259 OID 25101)
-- Name: ix_wr_work; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ix_wr_work ON public.work_resources USING btree (work_id);


--
-- TOC entry 4771 (class 1259 OID 25127)
-- Name: ux_work_schedules_work; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX ux_work_schedules_work ON public.work_schedules USING btree (work_id);


--
-- TOC entry 4810 (class 2620 OID 25154)
-- Name: work_categories tg_work_categories_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER tg_work_categories_updated_at BEFORE UPDATE ON public.work_categories FOR EACH ROW EXECUTE FUNCTION public.trg_set_updated_at();


--
-- TOC entry 4803 (class 2606 OID 25192)
-- Name: work_resources fk_work_resources_object; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_resources
    ADD CONSTRAINT fk_work_resources_object FOREIGN KEY (object_id) REFERENCES public.objects(id) ON DELETE RESTRICT;


--
-- TOC entry 4807 (class 2606 OID 25204)
-- Name: work_schedules fk_work_schedules_object; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_schedules
    ADD CONSTRAINT fk_work_schedules_object FOREIGN KEY (object_id) REFERENCES public.objects(id) ON DELETE RESTRICT;


--
-- TOC entry 4799 (class 2606 OID 25157)
-- Name: works fk_works_category; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.works
    ADD CONSTRAINT fk_works_category FOREIGN KEY (work_category_id) REFERENCES public.work_categories(id) ON DELETE RESTRICT;


--
-- TOC entry 4800 (class 2606 OID 25210)
-- Name: works fk_works_object; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.works
    ADD CONSTRAINT fk_works_object FOREIGN KEY (object_id) REFERENCES public.objects(id) ON DELETE RESTRICT;


--
-- TOC entry 4797 (class 2606 OID 25003)
-- Name: object_parts object_parts_object_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.object_parts
    ADD CONSTRAINT object_parts_object_id_fkey FOREIGN KEY (object_id) REFERENCES public.objects(id) ON DELETE CASCADE;


--
-- TOC entry 4796 (class 2606 OID 24986)
-- Name: objects objects_project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.objects
    ADD CONSTRAINT objects_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE RESTRICT;


--
-- TOC entry 4795 (class 2606 OID 24969)
-- Name: projects projects_kontragent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.projects
    ADD CONSTRAINT projects_kontragent_id_fkey FOREIGN KEY (customer_id) REFERENCES public.customers(id) ON DELETE RESTRICT;


--
-- TOC entry 4798 (class 2606 OID 25044)
-- Name: resource_catalog resource_catalog_unit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.resource_catalog
    ADD CONSTRAINT resource_catalog_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES public.units(id);


--
-- TOC entry 4809 (class 2606 OID 25145)
-- Name: work_categories work_categories_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_categories
    ADD CONSTRAINT work_categories_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES public.work_categories(id) ON DELETE SET NULL;


--
-- TOC entry 4804 (class 2606 OID 25091)
-- Name: work_resources work_resources_resource_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_resources
    ADD CONSTRAINT work_resources_resource_id_fkey FOREIGN KEY (resource_id) REFERENCES public.resource_catalog(id);


--
-- TOC entry 4805 (class 2606 OID 25096)
-- Name: work_resources work_resources_unit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_resources
    ADD CONSTRAINT work_resources_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES public.units(id);


--
-- TOC entry 4806 (class 2606 OID 25086)
-- Name: work_resources work_resources_work_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_resources
    ADD CONSTRAINT work_resources_work_id_fkey FOREIGN KEY (work_id) REFERENCES public.works(id) ON DELETE RESTRICT;


--
-- TOC entry 4808 (class 2606 OID 25122)
-- Name: work_schedules work_schedules_work_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.work_schedules
    ADD CONSTRAINT work_schedules_work_id_fkey FOREIGN KEY (work_id) REFERENCES public.works(id) ON DELETE RESTRICT;


--
-- TOC entry 4801 (class 2606 OID 25063)
-- Name: works works_object_part_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.works
    ADD CONSTRAINT works_object_part_id_fkey FOREIGN KEY (object_part_id) REFERENCES public.object_parts(id) ON DELETE RESTRICT;


--
-- TOC entry 4802 (class 2606 OID 25068)
-- Name: works works_unit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.works
    ADD CONSTRAINT works_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES public.units(id);


-- Completed on 2025-11-06 22:54:06

--
--

