sharix_open_synced_schema.sql 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. --
  2. -- PostgreSQL database dump
  3. --
  4. -- Dumped from database version 12.7
  5. -- Dumped by pg_dump version 12.7
  6. SET statement_timeout = 0;
  7. SET lock_timeout = 0;
  8. SET idle_in_transaction_session_timeout = 0;
  9. SET client_encoding = 'UTF8';
  10. SET standard_conforming_strings = on;
  11. SELECT pg_catalog.set_config('search_path', '', false);
  12. SET check_function_bodies = false;
  13. SET xmloption = content;
  14. SET client_min_messages = warning;
  15. SET row_security = off;
  16. SET default_tablespace = '';
  17. SET default_table_access_method = heap;
  18. --
  19. -- Name: client; Type: TABLE; Schema: public; Owner: postgres
  20. --
  21. CREATE TABLE public.client (
  22. id integer NOT NULL,
  23. user_id integer NOT NULL,
  24. requirements name NOT NULL,
  25. status character(1) DEFAULT 'A'::bpchar,
  26. ticket_status integer,
  27. id_metaservice integer NOT NULL,
  28. is_global character(1) NOT NULL,
  29. is_visible character(1) NOT NULL
  30. );
  31. ALTER TABLE public.client OWNER TO postgres;
  32. --
  33. -- Name: client_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  34. --
  35. CREATE SEQUENCE public.client_id_seq
  36. AS integer
  37. START WITH 1
  38. INCREMENT BY 1
  39. NO MINVALUE
  40. NO MAXVALUE
  41. CACHE 1;
  42. ALTER TABLE public.client_id_seq OWNER TO postgres;
  43. --
  44. -- Name: client_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  45. --
  46. ALTER SEQUENCE public.client_id_seq OWNED BY public.client.id;
  47. --
  48. -- Name: company; Type: TABLE; Schema: public; Owner: postgres
  49. --
  50. CREATE TABLE public.company (
  51. id integer NOT NULL,
  52. legal_name character varying(255) NOT NULL,
  53. repr_id integer NOT NULL,
  54. kpp character varying(9) NOT NULL,
  55. ogrn character varying(13) NOT NULL,
  56. bank_name character varying(255) NOT NULL,
  57. bik character varying(9) NOT NULL,
  58. ks integer NOT NULL,
  59. rs integer NOT NULL,
  60. address character varying(255) NOT NULL,
  61. id_metaservice integer,
  62. is_global character(1) NOT NULL,
  63. is_visible character(1) NOT NULL,
  64. requirements name,
  65. status character(1) DEFAULT 'A'::bpchar,
  66. ticket_status integer
  67. );
  68. ALTER TABLE public.company OWNER TO postgres;
  69. --
  70. -- Name: company_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  71. --
  72. CREATE SEQUENCE public.company_id_seq
  73. AS integer
  74. START WITH 1
  75. INCREMENT BY 1
  76. NO MINVALUE
  77. NO MAXVALUE
  78. CACHE 1;
  79. ALTER TABLE public.company_id_seq OWNER TO postgres;
  80. --
  81. -- Name: company_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  82. --
  83. ALTER SEQUENCE public.company_id_seq OWNED BY public.company.id;
  84. --
  85. -- Name: current_orders; Type: TABLE; Schema: public; Owner: postgres
  86. --
  87. CREATE TABLE public.current_orders (
  88. id integer NOT NULL,
  89. service_id integer NOT NULL,
  90. service_type_id integer NOT NULL,
  91. state integer NOT NULL,
  92. id_metaservice integer NOT NULL,
  93. time_created timestamp with time zone NOT NULL,
  94. time_placed timestamp with time zone NOT NULL,
  95. time_start timestamp with time zone NOT NULL,
  96. time_finish_predicted timestamp with time zone NOT NULL,
  97. time_finish_real timestamp with time zone NOT NULL,
  98. provider_id integer NOT NULL,
  99. receiver_id integer NOT NULL,
  100. client_id integer NOT NULL,
  101. predicted_price money NOT NULL,
  102. real_price money NOT NULL,
  103. is_global character(1) NOT NULL,
  104. is_visible character(1) NOT NULL
  105. );
  106. ALTER TABLE public.current_orders OWNER TO postgres;
  107. --
  108. -- Name: current_orders_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  109. --
  110. CREATE SEQUENCE public.current_orders_id_seq
  111. AS integer
  112. START WITH 1
  113. INCREMENT BY 1
  114. NO MINVALUE
  115. NO MAXVALUE
  116. CACHE 1;
  117. ALTER TABLE public.current_orders_id_seq OWNER TO postgres;
  118. --
  119. -- Name: current_orders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  120. --
  121. ALTER SEQUENCE public.current_orders_id_seq OWNED BY public.current_orders.id;
  122. --
  123. -- Name: documents; Type: TABLE; Schema: public; Owner: postgres
  124. --
  125. CREATE TABLE public.documents (
  126. id integer NOT NULL,
  127. id_metaservice integer NOT NULL,
  128. doctype character varying(2) NOT NULL,
  129. expire_date date NOT NULL,
  130. datalink name,
  131. user_id integer NOT NULL,
  132. company_id integer,
  133. is_global character(1) NOT NULL,
  134. is_visible character(1) NOT NULL,
  135. check_level character(1),
  136. check_by integer,
  137. check_date timestamp with time zone,
  138. status character(1),
  139. ticket_status integer
  140. );
  141. ALTER TABLE public.documents OWNER TO postgres;
  142. --
  143. -- Name: documents_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  144. --
  145. CREATE SEQUENCE public.documents_id_seq
  146. AS integer
  147. START WITH 1
  148. INCREMENT BY 1
  149. NO MINVALUE
  150. NO MAXVALUE
  151. CACHE 1;
  152. ALTER TABLE public.documents_id_seq OWNER TO postgres;
  153. --
  154. -- Name: documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  155. --
  156. ALTER SEQUENCE public.documents_id_seq OWNED BY public.documents.id;
  157. --
  158. -- Name: permissions; Type: TABLE; Schema: public; Owner: postgres
  159. --
  160. CREATE TABLE public.permissions (
  161. id integer NOT NULL,
  162. id_metaservice integer NOT NULL,
  163. id_permission integer NOT NULL,
  164. user_id integer NOT NULL,
  165. is_global character(1) NOT NULL,
  166. is_visible character(1) NOT NULL,
  167. check_level character(1),
  168. check_by integer,
  169. check_date timestamp with time zone NOT NULL,
  170. status character(1),
  171. ticket_status integer
  172. );
  173. ALTER TABLE public.permissions OWNER TO postgres;
  174. --
  175. -- Name: permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  176. --
  177. CREATE SEQUENCE public.permissions_id_seq
  178. AS integer
  179. START WITH 1
  180. INCREMENT BY 1
  181. NO MINVALUE
  182. NO MAXVALUE
  183. CACHE 1;
  184. ALTER TABLE public.permissions_id_seq OWNER TO postgres;
  185. --
  186. -- Name: permissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  187. --
  188. ALTER SEQUENCE public.permissions_id_seq OWNED BY public.permissions.id;
  189. --
  190. -- Name: provider; Type: TABLE; Schema: public; Owner: postgres
  191. --
  192. CREATE TABLE public.provider (
  193. id integer NOT NULL,
  194. type integer NOT NULL,
  195. id_company integer NOT NULL,
  196. user_id integer NOT NULL,
  197. requirements name NOT NULL,
  198. status character(1) DEFAULT 'A'::bpchar,
  199. ticket_status integer,
  200. id_metaservice integer NOT NULL,
  201. is_global character(1) NOT NULL,
  202. is_visible character(1) NOT NULL,
  203. location_type name NOT NULL,
  204. default_location name NOT NULL
  205. );
  206. ALTER TABLE public.provider OWNER TO postgres;
  207. --
  208. -- Name: provider_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  209. --
  210. CREATE SEQUENCE public.provider_id_seq
  211. AS integer
  212. START WITH 1
  213. INCREMENT BY 1
  214. NO MINVALUE
  215. NO MAXVALUE
  216. CACHE 1;
  217. ALTER TABLE public.provider_id_seq OWNER TO postgres;
  218. --
  219. -- Name: provider_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  220. --
  221. ALTER SEQUENCE public.provider_id_seq OWNED BY public.provider.id;
  222. --
  223. -- Name: relationship; Type: TABLE; Schema: public; Owner: postgres
  224. --
  225. CREATE TABLE public.relationship (
  226. id integer NOT NULL,
  227. user_id_who integer NOT NULL,
  228. user_id_whom integer NOT NULL,
  229. neg_type character(1) NOT NULL,
  230. id_metaservice integer,
  231. is_global character(1) NOT NULL,
  232. is_visible character(1) NOT NULL,
  233. requirements name,
  234. status character(1) DEFAULT 'A'::bpchar,
  235. ticket_status integer
  236. );
  237. ALTER TABLE public.relationship OWNER TO postgres;
  238. --
  239. -- Name: relationship_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  240. --
  241. CREATE SEQUENCE public.relationship_id_seq
  242. AS integer
  243. START WITH 1
  244. INCREMENT BY 1
  245. NO MINVALUE
  246. NO MAXVALUE
  247. CACHE 1;
  248. ALTER TABLE public.relationship_id_seq OWNER TO postgres;
  249. --
  250. -- Name: relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  251. --
  252. ALTER SEQUENCE public.relationship_id_seq OWNED BY public.relationship.id;
  253. --
  254. -- Name: resource; Type: TABLE; Schema: public; Owner: postgres
  255. --
  256. CREATE TABLE public.resource (
  257. id integer NOT NULL,
  258. type_id integer NOT NULL,
  259. user_id integer NOT NULL,
  260. requirements name NOT NULL,
  261. status character(1) DEFAULT 'A'::bpchar,
  262. ticket_status integer,
  263. id_metaservice integer NOT NULL,
  264. is_global character(1) NOT NULL,
  265. is_visible character(1) NOT NULL
  266. );
  267. ALTER TABLE public.resource OWNER TO postgres;
  268. --
  269. -- Name: resource_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  270. --
  271. CREATE SEQUENCE public.resource_id_seq
  272. AS integer
  273. START WITH 1
  274. INCREMENT BY 1
  275. NO MINVALUE
  276. NO MAXVALUE
  277. CACHE 1;
  278. ALTER TABLE public.resource_id_seq OWNER TO postgres;
  279. --
  280. -- Name: resource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  281. --
  282. ALTER SEQUENCE public.resource_id_seq OWNED BY public.resource.id;
  283. --
  284. -- Name: service; Type: TABLE; Schema: public; Owner: postgres
  285. --
  286. CREATE TABLE public.service (
  287. id integer NOT NULL,
  288. servicetype_id integer NOT NULL,
  289. id_provider integer NOT NULL,
  290. resourse_id integer NOT NULL,
  291. price_alg character varying(255) NOT NULL,
  292. price_km money NOT NULL,
  293. price_min money NOT NULL,
  294. price_amount money NOT NULL,
  295. id_metaservice integer,
  296. is_global character(1) NOT NULL,
  297. is_visible character(1) NOT NULL,
  298. requirements name,
  299. status character(1) DEFAULT 'A'::bpchar,
  300. ticket_status integer
  301. );
  302. ALTER TABLE public.service OWNER TO postgres;
  303. --
  304. -- Name: service_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  305. --
  306. CREATE SEQUENCE public.service_id_seq
  307. AS integer
  308. START WITH 1
  309. INCREMENT BY 1
  310. NO MINVALUE
  311. NO MAXVALUE
  312. CACHE 1;
  313. ALTER TABLE public.service_id_seq OWNER TO postgres;
  314. --
  315. -- Name: service_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  316. --
  317. ALTER SEQUENCE public.service_id_seq OWNED BY public.service.id;
  318. --
  319. -- Name: servicetype; Type: TABLE; Schema: public; Owner: postgres
  320. --
  321. CREATE TABLE public.servicetype (
  322. id integer NOT NULL,
  323. caption character varying(255) NOT NULL,
  324. description text NOT NULL,
  325. pricetype integer NOT NULL,
  326. id_metaservice integer,
  327. is_global character(1) NOT NULL,
  328. is_visible character(1) NOT NULL,
  329. requirements name,
  330. status character(1) DEFAULT 'A'::bpchar,
  331. ticket_status integer
  332. );
  333. ALTER TABLE public.servicetype OWNER TO postgres;
  334. --
  335. -- Name: servicetype_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  336. --
  337. CREATE SEQUENCE public.servicetype_id_seq
  338. AS integer
  339. START WITH 1
  340. INCREMENT BY 1
  341. NO MINVALUE
  342. NO MAXVALUE
  343. CACHE 1;
  344. ALTER TABLE public.servicetype_id_seq OWNER TO postgres;
  345. --
  346. -- Name: servicetype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  347. --
  348. ALTER SEQUENCE public.servicetype_id_seq OWNED BY public.servicetype.id;
  349. --
  350. -- Name: client id; Type: DEFAULT; Schema: public; Owner: postgres
  351. --
  352. ALTER TABLE ONLY public.client ALTER COLUMN id SET DEFAULT nextval('public.client_id_seq'::regclass);
  353. --
  354. -- Name: company id; Type: DEFAULT; Schema: public; Owner: postgres
  355. --
  356. ALTER TABLE ONLY public.company ALTER COLUMN id SET DEFAULT nextval('public.company_id_seq'::regclass);
  357. --
  358. -- Name: current_orders id; Type: DEFAULT; Schema: public; Owner: postgres
  359. --
  360. ALTER TABLE ONLY public.current_orders ALTER COLUMN id SET DEFAULT nextval('public.current_orders_id_seq'::regclass);
  361. --
  362. -- Name: documents id; Type: DEFAULT; Schema: public; Owner: postgres
  363. --
  364. ALTER TABLE ONLY public.documents ALTER COLUMN id SET DEFAULT nextval('public.documents_id_seq'::regclass);
  365. --
  366. -- Name: permissions id; Type: DEFAULT; Schema: public; Owner: postgres
  367. --
  368. ALTER TABLE ONLY public.permissions ALTER COLUMN id SET DEFAULT nextval('public.permissions_id_seq'::regclass);
  369. --
  370. -- Name: provider id; Type: DEFAULT; Schema: public; Owner: postgres
  371. --
  372. ALTER TABLE ONLY public.provider ALTER COLUMN id SET DEFAULT nextval('public.provider_id_seq'::regclass);
  373. --
  374. -- Name: relationship id; Type: DEFAULT; Schema: public; Owner: postgres
  375. --
  376. ALTER TABLE ONLY public.relationship ALTER COLUMN id SET DEFAULT nextval('public.relationship_id_seq'::regclass);
  377. --
  378. -- Name: resource id; Type: DEFAULT; Schema: public; Owner: postgres
  379. --
  380. ALTER TABLE ONLY public.resource ALTER COLUMN id SET DEFAULT nextval('public.resource_id_seq'::regclass);
  381. --
  382. -- Name: service id; Type: DEFAULT; Schema: public; Owner: postgres
  383. --
  384. ALTER TABLE ONLY public.service ALTER COLUMN id SET DEFAULT nextval('public.service_id_seq'::regclass);
  385. --
  386. -- Name: servicetype id; Type: DEFAULT; Schema: public; Owner: postgres
  387. --
  388. ALTER TABLE ONLY public.servicetype ALTER COLUMN id SET DEFAULT nextval('public.servicetype_id_seq'::regclass);
  389. --
  390. -- Name: client client_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  391. --
  392. ALTER TABLE ONLY public.client
  393. ADD CONSTRAINT client_pkey PRIMARY KEY (id);
  394. --
  395. -- Name: company company_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  396. --
  397. ALTER TABLE ONLY public.company
  398. ADD CONSTRAINT company_pkey PRIMARY KEY (id);
  399. --
  400. -- Name: current_orders current_orders_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  401. --
  402. ALTER TABLE ONLY public.current_orders
  403. ADD CONSTRAINT current_orders_pkey PRIMARY KEY (id);
  404. --
  405. -- Name: documents documents_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  406. --
  407. ALTER TABLE ONLY public.documents
  408. ADD CONSTRAINT documents_pkey PRIMARY KEY (id);
  409. --
  410. -- Name: permissions permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  411. --
  412. ALTER TABLE ONLY public.permissions
  413. ADD CONSTRAINT permissions_pkey PRIMARY KEY (id);
  414. --
  415. -- Name: provider provider_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  416. --
  417. ALTER TABLE ONLY public.provider
  418. ADD CONSTRAINT provider_pkey PRIMARY KEY (id);
  419. --
  420. -- Name: relationship relationship_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  421. --
  422. ALTER TABLE ONLY public.relationship
  423. ADD CONSTRAINT relationship_pkey PRIMARY KEY (id);
  424. --
  425. -- Name: resource resource_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  426. --
  427. ALTER TABLE ONLY public.resource
  428. ADD CONSTRAINT resource_pkey PRIMARY KEY (id);
  429. --
  430. -- Name: service service_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  431. --
  432. ALTER TABLE ONLY public.service
  433. ADD CONSTRAINT service_pkey PRIMARY KEY (id);
  434. --
  435. -- Name: servicetype servicetype_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  436. --
  437. ALTER TABLE ONLY public.servicetype
  438. ADD CONSTRAINT servicetype_pkey PRIMARY KEY (id);
  439. --
  440. -- Name: current_orders current_orders_client_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  441. --
  442. ALTER TABLE ONLY public.current_orders
  443. ADD CONSTRAINT current_orders_client_id_fkey FOREIGN KEY (client_id) REFERENCES public.client(id);
  444. --
  445. -- Name: current_orders current_orders_provider_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  446. --
  447. ALTER TABLE ONLY public.current_orders
  448. ADD CONSTRAINT current_orders_provider_id_fkey FOREIGN KEY (provider_id) REFERENCES public.provider(id);
  449. --
  450. -- Name: current_orders current_orders_service_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  451. --
  452. ALTER TABLE ONLY public.current_orders
  453. ADD CONSTRAINT current_orders_service_id_fkey FOREIGN KEY (service_id) REFERENCES public.service(id);
  454. --
  455. -- Name: current_orders current_orders_service_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  456. --
  457. ALTER TABLE ONLY public.current_orders
  458. ADD CONSTRAINT current_orders_service_type_id_fkey FOREIGN KEY (service_type_id) REFERENCES public.servicetype(id);
  459. --
  460. -- Name: documents documents_company_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  461. --
  462. ALTER TABLE ONLY public.documents
  463. ADD CONSTRAINT documents_company_id_fkey FOREIGN KEY (company_id) REFERENCES public.company(id);
  464. --
  465. -- Name: service service_id_provider_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  466. --
  467. ALTER TABLE ONLY public.service
  468. ADD CONSTRAINT service_id_provider_fkey FOREIGN KEY (id_provider) REFERENCES public.provider(id);
  469. --
  470. -- Name: service service_resourse_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  471. --
  472. ALTER TABLE ONLY public.service
  473. ADD CONSTRAINT service_resourse_id_fkey FOREIGN KEY (resourse_id) REFERENCES public.resource(id);
  474. --
  475. -- Name: service service_servicetype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  476. --
  477. ALTER TABLE ONLY public.service
  478. ADD CONSTRAINT service_servicetype_id_fkey FOREIGN KEY (servicetype_id) REFERENCES public.servicetype(id);
  479. --
  480. -- PostgreSQL database dump complete
  481. --