· 5 years ago · May 05, 2020, 03:28 PM
1--
2-- PostgreSQL database dump
3--
4
5-- Dumped from database version 12.1 (Debian 12.1-1.pgdg100+1)
6-- Dumped by pg_dump version 12.1 (Debian 12.1-1.pgdg100+1)
7
8SET statement_timeout = 0;
9SET lock_timeout = 0;
10SET idle_in_transaction_session_timeout = 0;
11SET client_encoding = 'UTF8';
12SET standard_conforming_strings = on;
13SELECT pg_catalog.set_config('search_path', '', false);
14SET check_function_bodies = false;
15SET xmloption = content;
16SET client_min_messages = warning;
17SET row_security = off;
18
19--
20-- Name: hdb_catalog; Type: SCHEMA; Schema: -; Owner: postgres
21--
22
23CREATE SCHEMA hdb_catalog;
24
25
26ALTER SCHEMA hdb_catalog OWNER TO postgres;
27
28--
29-- Name: hdb_views; Type: SCHEMA; Schema: -; Owner: postgres
30--
31
32CREATE SCHEMA hdb_views;
33
34
35ALTER SCHEMA hdb_views OWNER TO postgres;
36
37--
38-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: -
39--
40
41CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
42
43
44--
45-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner:
46--
47
48COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
49
50
51--
52-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
53--
54
55CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
56
57
58--
59-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner:
60--
61
62COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions';
63
64
65--
66-- Name: check_violation(text); Type: FUNCTION; Schema: hdb_catalog; Owner: postgres
67--
68
69CREATE FUNCTION hdb_catalog.check_violation(msg text) RETURNS boolean
70 LANGUAGE plpgsql
71 AS $$
72 BEGIN
73 RAISE check_violation USING message=msg;
74 END;
75$$;
76
77
78ALTER FUNCTION hdb_catalog.check_violation(msg text) OWNER TO postgres;
79
80--
81-- Name: hdb_schema_update_event_notifier(); Type: FUNCTION; Schema: hdb_catalog; Owner: postgres
82--
83
84CREATE FUNCTION hdb_catalog.hdb_schema_update_event_notifier() RETURNS trigger
85 LANGUAGE plpgsql
86 AS $$
87 DECLARE
88 instance_id uuid;
89 occurred_at timestamptz;
90 invalidations json;
91 curr_rec record;
92 BEGIN
93 instance_id = NEW.instance_id;
94 occurred_at = NEW.occurred_at;
95 invalidations = NEW.invalidations;
96 PERFORM pg_notify('hasura_schema_update', json_build_object(
97 'instance_id', instance_id,
98 'occurred_at', occurred_at,
99 'invalidations', invalidations
100 )::text);
101 RETURN curr_rec;
102 END;
103$$;
104
105
106ALTER FUNCTION hdb_catalog.hdb_schema_update_event_notifier() OWNER TO postgres;
107
108--
109-- Name: inject_table_defaults(text, text, text, text); Type: FUNCTION; Schema: hdb_catalog; Owner: postgres
110--
111
112CREATE FUNCTION hdb_catalog.inject_table_defaults(view_schema text, view_name text, tab_schema text, tab_name text) RETURNS void
113 LANGUAGE plpgsql
114 AS $$
115 DECLARE
116 r RECORD;
117 BEGIN
118 FOR r IN SELECT column_name, column_default FROM information_schema.columns WHERE table_schema = tab_schema AND table_name = tab_name AND column_default IS NOT NULL LOOP
119 EXECUTE format('ALTER VIEW %I.%I ALTER COLUMN %I SET DEFAULT %s;', view_schema, view_name, r.column_name, r.column_default);
120 END LOOP;
121 END;
122$$;
123
124
125ALTER FUNCTION hdb_catalog.inject_table_defaults(view_schema text, view_name text, tab_schema text, tab_name text) OWNER TO postgres;
126
127--
128-- Name: insert_event_log(text, text, text, text, json); Type: FUNCTION; Schema: hdb_catalog; Owner: postgres
129--
130
131CREATE FUNCTION hdb_catalog.insert_event_log(schema_name text, table_name text, trigger_name text, op text, row_data json) RETURNS text
132 LANGUAGE plpgsql
133 AS $$
134 DECLARE
135 id text;
136 payload json;
137 session_variables json;
138 server_version_num int;
139 BEGIN
140 id := gen_random_uuid();
141 server_version_num := current_setting('server_version_num');
142 IF server_version_num >= 90600 THEN
143 session_variables := current_setting('hasura.user', 't');
144 ELSE
145 BEGIN
146 session_variables := current_setting('hasura.user');
147 EXCEPTION WHEN OTHERS THEN
148 session_variables := NULL;
149 END;
150 END IF;
151 payload := json_build_object(
152 'op', op,
153 'data', row_data,
154 'session_variables', session_variables
155 );
156 INSERT INTO hdb_catalog.event_log
157 (id, schema_name, table_name, trigger_name, payload)
158 VALUES
159 (id, schema_name, table_name, trigger_name, payload);
160 RETURN id;
161 END;
162$$;
163
164
165ALTER FUNCTION hdb_catalog.insert_event_log(schema_name text, table_name text, trigger_name text, op text, row_data json) OWNER TO postgres;
166
167--
168-- Name: notify_hasura_onEntityCreated_INSERT(); Type: FUNCTION; Schema: hdb_views; Owner: postgres
169--
170
171CREATE FUNCTION hdb_views."notify_hasura_onEntityCreated_INSERT"() RETURNS trigger
172 LANGUAGE plpgsql
173 AS $$
174 DECLARE
175 _old record;
176 _new record;
177 _data json;
178 BEGIN
179 IF TG_OP = 'UPDATE' THEN
180 _old := row(OLD );
181 _new := row(NEW );
182 ELSE
183 /* initialize _old and _new with dummy values for INSERT and UPDATE events*/
184 _old := row((select 1));
185 _new := row((select 1));
186 END IF;
187 _data := json_build_object(
188 'old', NULL,
189 'new', row_to_json(NEW )
190 );
191 BEGIN
192 IF (TG_OP <> 'UPDATE') OR (_old <> _new) THEN
193 PERFORM hdb_catalog.insert_event_log(CAST(TG_TABLE_SCHEMA AS text), CAST(TG_TABLE_NAME AS text), CAST('onEntityCreated' AS text), TG_OP, _data);
194 END IF;
195 EXCEPTION WHEN undefined_function THEN
196 IF (TG_OP <> 'UPDATE') OR (_old *<> _new) THEN
197 PERFORM hdb_catalog.insert_event_log(CAST(TG_TABLE_SCHEMA AS text), CAST(TG_TABLE_NAME AS text), CAST('onEntityCreated' AS text), TG_OP, _data);
198 END IF;
199 END;
200
201 RETURN NULL;
202 END;
203$$;
204
205
206ALTER FUNCTION hdb_views."notify_hasura_onEntityCreated_INSERT"() OWNER TO postgres;
207
208SET default_tablespace = '';
209
210SET default_table_access_method = heap;
211
212--
213-- Name: Driver; Type: TABLE; Schema: public; Owner: postgres
214--
215
216CREATE TABLE public."Driver" (
217 "secondName" text NOT NULL,
218 "firstName" text NOT NULL,
219 "middleName" text NOT NULL,
220 gender text DEFAULT 'man'::text NOT NULL,
221 language text DEFAULT 'ru'::text NOT NULL,
222 comments text,
223 created_at timestamp with time zone DEFAULT now(),
224 updated_at timestamp with time zone DEFAULT now(),
225 "organizationId" uuid NOT NULL,
226 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
227 "isRemoved" boolean DEFAULT false NOT NULL,
228 "intermediaryId" uuid,
229 phones jsonb DEFAULT jsonb_build_array(),
230 emails jsonb DEFAULT jsonb_build_array(),
231 "officeId" uuid NOT NULL,
232 birthdate date NOT NULL,
233 status text DEFAULT 'created'::text NOT NULL,
234 photo text,
235 "drivingLicenseNumber" text,
236 "contractId" uuid,
237 "verificationCode" text
238);
239
240
241ALTER TABLE public."Driver" OWNER TO postgres;
242
243--
244-- Name: driver_full_name(public."Driver"); Type: FUNCTION; Schema: public; Owner: postgres
245--
246
247CREATE FUNCTION public.driver_full_name(driver_row public."Driver") RETURNS text
248 LANGUAGE sql STABLE
249 AS $$
250 SELECT driver_row."secondName" || ' ' || driver_row."firstName" || ' ' || driver_row."middleName"
251$$;
252
253
254ALTER FUNCTION public.driver_full_name(driver_row public."Driver") OWNER TO postgres;
255
256--
257-- Name: get_next_number(); Type: FUNCTION; Schema: public; Owner: postgres
258--
259
260CREATE FUNCTION public.get_next_number() RETURNS trigger
261 LANGUAGE plpgsql
262 AS $$
263BEGIN
264 NEW.C1 := 0;
265 RETURN NEW;
266END
267$$;
268
269
270ALTER FUNCTION public.get_next_number() OWNER TO postgres;
271
272--
273-- Name: search_driver(text); Type: FUNCTION; Schema: public; Owner: postgres
274--
275
276CREATE FUNCTION public.search_driver(search text) RETURNS SETOF public."Driver"
277 LANGUAGE sql STABLE
278 AS $$
279 SELECT *
280 FROM "Driver"
281 WHERE
282 search <% ("secondName" || ' ' || "firstName" || ' ' || "middleName")
283 ORDER BY
284 similarity(search, ("secondName" || ' ' || "firstName" || ' ' || "middleName")) DESC
285 LIMIT 10;
286$$;
287
288
289ALTER FUNCTION public.search_driver(search text) OWNER TO postgres;
290
291--
292-- Name: set_current_timestamp_updatedAt(); Type: FUNCTION; Schema: public; Owner: postgres
293--
294
295CREATE FUNCTION public."set_current_timestamp_updatedAt"() RETURNS trigger
296 LANGUAGE plpgsql
297 AS $$
298DECLARE
299 _new record;
300BEGIN
301 _new := NEW;
302 _new."updatedAt" = NOW();
303 RETURN _new;
304END;
305$$;
306
307
308ALTER FUNCTION public."set_current_timestamp_updatedAt"() OWNER TO postgres;
309
310--
311-- Name: set_current_timestamp_updated_at(); Type: FUNCTION; Schema: public; Owner: postgres
312--
313
314CREATE FUNCTION public.set_current_timestamp_updated_at() RETURNS trigger
315 LANGUAGE plpgsql
316 AS $$
317DECLARE
318 _new record;
319BEGIN
320 _new := NEW;
321 _new."updated_at" = NOW();
322 RETURN _new;
323END;
324$$;
325
326
327ALTER FUNCTION public.set_current_timestamp_updated_at() OWNER TO postgres;
328
329--
330-- Name: test_func(); Type: FUNCTION; Schema: public; Owner: postgres
331--
332
333CREATE FUNCTION public.test_func() RETURNS trigger
334 LANGUAGE plpgsql
335 AS $$
336 BEGIN
337 NEW.number := 10;
338 RETURN NEW;
339 END;
340 $$;
341
342
343ALTER FUNCTION public.test_func() OWNER TO postgres;
344
345--
346-- Name: ttest(text); Type: FUNCTION; Schema: public; Owner: postgres
347--
348
349CREATE FUNCTION public.ttest(search text) RETURNS text
350 LANGUAGE sql STABLE
351 AS $$
352SELECT search
353$$;
354
355
356ALTER FUNCTION public.ttest(search text) OWNER TO postgres;
357
358--
359-- Name: event_invocation_logs; Type: TABLE; Schema: hdb_catalog; Owner: postgres
360--
361
362CREATE TABLE hdb_catalog.event_invocation_logs (
363 id text DEFAULT public.gen_random_uuid() NOT NULL,
364 event_id text,
365 status integer,
366 request json,
367 response json,
368 created_at timestamp without time zone DEFAULT now()
369);
370
371
372ALTER TABLE hdb_catalog.event_invocation_logs OWNER TO postgres;
373
374--
375-- Name: event_log; Type: TABLE; Schema: hdb_catalog; Owner: postgres
376--
377
378CREATE TABLE hdb_catalog.event_log (
379 id text DEFAULT public.gen_random_uuid() NOT NULL,
380 schema_name text NOT NULL,
381 table_name text NOT NULL,
382 trigger_name text NOT NULL,
383 payload jsonb NOT NULL,
384 delivered boolean DEFAULT false NOT NULL,
385 error boolean DEFAULT false NOT NULL,
386 tries integer DEFAULT 0 NOT NULL,
387 created_at timestamp without time zone DEFAULT now(),
388 locked boolean DEFAULT false NOT NULL,
389 next_retry_at timestamp without time zone,
390 archived boolean DEFAULT false NOT NULL
391);
392
393
394ALTER TABLE hdb_catalog.event_log OWNER TO postgres;
395
396--
397-- Name: event_triggers; Type: TABLE; Schema: hdb_catalog; Owner: postgres
398--
399
400CREATE TABLE hdb_catalog.event_triggers (
401 name text NOT NULL,
402 type text NOT NULL,
403 schema_name text NOT NULL,
404 table_name text NOT NULL,
405 configuration json,
406 comment text
407);
408
409
410ALTER TABLE hdb_catalog.event_triggers OWNER TO postgres;
411
412--
413-- Name: hdb_action; Type: TABLE; Schema: hdb_catalog; Owner: postgres
414--
415
416CREATE TABLE hdb_catalog.hdb_action (
417 action_name text NOT NULL,
418 action_defn jsonb NOT NULL,
419 comment text,
420 is_system_defined boolean DEFAULT false
421);
422
423
424ALTER TABLE hdb_catalog.hdb_action OWNER TO postgres;
425
426--
427-- Name: hdb_action_log; Type: TABLE; Schema: hdb_catalog; Owner: postgres
428--
429
430CREATE TABLE hdb_catalog.hdb_action_log (
431 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
432 action_name text,
433 input_payload jsonb NOT NULL,
434 request_headers jsonb NOT NULL,
435 session_variables jsonb NOT NULL,
436 response_payload jsonb,
437 errors jsonb,
438 created_at timestamp with time zone DEFAULT now() NOT NULL,
439 response_received_at timestamp with time zone,
440 status text NOT NULL,
441 CONSTRAINT hdb_action_log_status_check CHECK ((status = ANY (ARRAY['created'::text, 'processing'::text, 'completed'::text, 'error'::text])))
442);
443
444
445ALTER TABLE hdb_catalog.hdb_action_log OWNER TO postgres;
446
447--
448-- Name: hdb_action_permission; Type: TABLE; Schema: hdb_catalog; Owner: postgres
449--
450
451CREATE TABLE hdb_catalog.hdb_action_permission (
452 action_name text NOT NULL,
453 role_name text NOT NULL,
454 definition jsonb DEFAULT '{}'::jsonb NOT NULL,
455 comment text
456);
457
458
459ALTER TABLE hdb_catalog.hdb_action_permission OWNER TO postgres;
460
461--
462-- Name: hdb_allowlist; Type: TABLE; Schema: hdb_catalog; Owner: postgres
463--
464
465CREATE TABLE hdb_catalog.hdb_allowlist (
466 collection_name text
467);
468
469
470ALTER TABLE hdb_catalog.hdb_allowlist OWNER TO postgres;
471
472--
473-- Name: hdb_check_constraint; Type: VIEW; Schema: hdb_catalog; Owner: postgres
474--
475
476CREATE VIEW hdb_catalog.hdb_check_constraint AS
477 SELECT (n.nspname)::text AS table_schema,
478 (ct.relname)::text AS table_name,
479 (r.conname)::text AS constraint_name,
480 pg_get_constraintdef(r.oid, true) AS "check"
481 FROM ((pg_constraint r
482 JOIN pg_class ct ON ((r.conrelid = ct.oid)))
483 JOIN pg_namespace n ON ((ct.relnamespace = n.oid)))
484 WHERE (r.contype = 'c'::"char");
485
486
487ALTER TABLE hdb_catalog.hdb_check_constraint OWNER TO postgres;
488
489--
490-- Name: hdb_computed_field; Type: TABLE; Schema: hdb_catalog; Owner: postgres
491--
492
493CREATE TABLE hdb_catalog.hdb_computed_field (
494 table_schema text NOT NULL,
495 table_name text NOT NULL,
496 computed_field_name text NOT NULL,
497 definition jsonb NOT NULL,
498 comment text
499);
500
501
502ALTER TABLE hdb_catalog.hdb_computed_field OWNER TO postgres;
503
504--
505-- Name: hdb_computed_field_function; Type: VIEW; Schema: hdb_catalog; Owner: postgres
506--
507
508CREATE VIEW hdb_catalog.hdb_computed_field_function AS
509 SELECT hdb_computed_field.table_schema,
510 hdb_computed_field.table_name,
511 hdb_computed_field.computed_field_name,
512 CASE
513 WHEN (((hdb_computed_field.definition -> 'function'::text) ->> 'name'::text) IS NULL) THEN (hdb_computed_field.definition ->> 'function'::text)
514 ELSE ((hdb_computed_field.definition -> 'function'::text) ->> 'name'::text)
515 END AS function_name,
516 CASE
517 WHEN (((hdb_computed_field.definition -> 'function'::text) ->> 'schema'::text) IS NULL) THEN 'public'::text
518 ELSE ((hdb_computed_field.definition -> 'function'::text) ->> 'schema'::text)
519 END AS function_schema
520 FROM hdb_catalog.hdb_computed_field;
521
522
523ALTER TABLE hdb_catalog.hdb_computed_field_function OWNER TO postgres;
524
525--
526-- Name: hdb_custom_types; Type: TABLE; Schema: hdb_catalog; Owner: postgres
527--
528
529CREATE TABLE hdb_catalog.hdb_custom_types (
530 custom_types jsonb NOT NULL
531);
532
533
534ALTER TABLE hdb_catalog.hdb_custom_types OWNER TO postgres;
535
536--
537-- Name: hdb_foreign_key_constraint; Type: VIEW; Schema: hdb_catalog; Owner: postgres
538--
539
540CREATE VIEW hdb_catalog.hdb_foreign_key_constraint AS
541 SELECT (q.table_schema)::text AS table_schema,
542 (q.table_name)::text AS table_name,
543 (q.constraint_name)::text AS constraint_name,
544 (min(q.constraint_oid))::integer AS constraint_oid,
545 min((q.ref_table_table_schema)::text) AS ref_table_table_schema,
546 min((q.ref_table)::text) AS ref_table,
547 json_object_agg(ac.attname, afc.attname) AS column_mapping,
548 min((q.confupdtype)::text) AS on_update,
549 min((q.confdeltype)::text) AS on_delete,
550 json_agg(ac.attname) AS columns,
551 json_agg(afc.attname) AS ref_columns
552 FROM ((( SELECT ctn.nspname AS table_schema,
553 ct.relname AS table_name,
554 r.conrelid AS table_id,
555 r.conname AS constraint_name,
556 r.oid AS constraint_oid,
557 cftn.nspname AS ref_table_table_schema,
558 cft.relname AS ref_table,
559 r.confrelid AS ref_table_id,
560 r.confupdtype,
561 r.confdeltype,
562 unnest(r.conkey) AS column_id,
563 unnest(r.confkey) AS ref_column_id
564 FROM ((((pg_constraint r
565 JOIN pg_class ct ON ((r.conrelid = ct.oid)))
566 JOIN pg_namespace ctn ON ((ct.relnamespace = ctn.oid)))
567 JOIN pg_class cft ON ((r.confrelid = cft.oid)))
568 JOIN pg_namespace cftn ON ((cft.relnamespace = cftn.oid)))
569 WHERE (r.contype = 'f'::"char")) q
570 JOIN pg_attribute ac ON (((q.column_id = ac.attnum) AND (q.table_id = ac.attrelid))))
571 JOIN pg_attribute afc ON (((q.ref_column_id = afc.attnum) AND (q.ref_table_id = afc.attrelid))))
572 GROUP BY q.table_schema, q.table_name, q.constraint_name;
573
574
575ALTER TABLE hdb_catalog.hdb_foreign_key_constraint OWNER TO postgres;
576
577--
578-- Name: hdb_function; Type: TABLE; Schema: hdb_catalog; Owner: postgres
579--
580
581CREATE TABLE hdb_catalog.hdb_function (
582 function_schema text NOT NULL,
583 function_name text NOT NULL,
584 configuration jsonb DEFAULT '{}'::jsonb NOT NULL,
585 is_system_defined boolean DEFAULT false
586);
587
588
589ALTER TABLE hdb_catalog.hdb_function OWNER TO postgres;
590
591--
592-- Name: hdb_function_agg; Type: VIEW; Schema: hdb_catalog; Owner: postgres
593--
594
595CREATE VIEW hdb_catalog.hdb_function_agg AS
596 SELECT (p.proname)::text AS function_name,
597 (pn.nspname)::text AS function_schema,
598 pd.description,
599 CASE
600 WHEN (p.provariadic = (0)::oid) THEN false
601 ELSE true
602 END AS has_variadic,
603 CASE
604 WHEN ((p.provolatile)::text = ('i'::character(1))::text) THEN 'IMMUTABLE'::text
605 WHEN ((p.provolatile)::text = ('s'::character(1))::text) THEN 'STABLE'::text
606 WHEN ((p.provolatile)::text = ('v'::character(1))::text) THEN 'VOLATILE'::text
607 ELSE NULL::text
608 END AS function_type,
609 pg_get_functiondef(p.oid) AS function_definition,
610 (rtn.nspname)::text AS return_type_schema,
611 (rt.typname)::text AS return_type_name,
612 (rt.typtype)::text AS return_type_type,
613 p.proretset AS returns_set,
614 ( SELECT COALESCE(json_agg(json_build_object('schema', q.schema, 'name', q.name, 'type', q.type)), '[]'::json) AS "coalesce"
615 FROM ( SELECT pt.typname AS name,
616 pns.nspname AS schema,
617 pt.typtype AS type,
618 pat.ordinality
619 FROM ((unnest(COALESCE(p.proallargtypes, (p.proargtypes)::oid[])) WITH ORDINALITY pat(oid, ordinality)
620 LEFT JOIN pg_type pt ON ((pt.oid = pat.oid)))
621 LEFT JOIN pg_namespace pns ON ((pt.typnamespace = pns.oid)))
622 ORDER BY pat.ordinality) q) AS input_arg_types,
623 to_json(COALESCE(p.proargnames, ARRAY[]::text[])) AS input_arg_names,
624 p.pronargdefaults AS default_args,
625 (p.oid)::integer AS function_oid
626 FROM ((((pg_proc p
627 JOIN pg_namespace pn ON ((pn.oid = p.pronamespace)))
628 JOIN pg_type rt ON ((rt.oid = p.prorettype)))
629 JOIN pg_namespace rtn ON ((rtn.oid = rt.typnamespace)))
630 LEFT JOIN pg_description pd ON ((p.oid = pd.objoid)))
631 WHERE (((pn.nspname)::text !~~ 'pg_%'::text) AND ((pn.nspname)::text <> ALL (ARRAY['information_schema'::text, 'hdb_catalog'::text, 'hdb_views'::text])) AND (NOT (EXISTS ( SELECT 1
632 FROM pg_aggregate
633 WHERE ((pg_aggregate.aggfnoid)::oid = p.oid)))));
634
635
636ALTER TABLE hdb_catalog.hdb_function_agg OWNER TO postgres;
637
638--
639-- Name: hdb_function_info_agg; Type: VIEW; Schema: hdb_catalog; Owner: postgres
640--
641
642CREATE VIEW hdb_catalog.hdb_function_info_agg AS
643 SELECT hdb_function_agg.function_name,
644 hdb_function_agg.function_schema,
645 row_to_json(( SELECT e.*::record AS e
646 FROM ( SELECT hdb_function_agg.description,
647 hdb_function_agg.has_variadic,
648 hdb_function_agg.function_type,
649 hdb_function_agg.return_type_schema,
650 hdb_function_agg.return_type_name,
651 hdb_function_agg.return_type_type,
652 hdb_function_agg.returns_set,
653 hdb_function_agg.input_arg_types,
654 hdb_function_agg.input_arg_names,
655 hdb_function_agg.default_args,
656 (EXISTS ( SELECT 1
657 FROM information_schema.tables
658 WHERE (((tables.table_schema)::name = hdb_function_agg.return_type_schema) AND ((tables.table_name)::name = hdb_function_agg.return_type_name)))) AS returns_table) e)) AS function_info
659 FROM hdb_catalog.hdb_function_agg;
660
661
662ALTER TABLE hdb_catalog.hdb_function_info_agg OWNER TO postgres;
663
664--
665-- Name: hdb_permission; Type: TABLE; Schema: hdb_catalog; Owner: postgres
666--
667
668CREATE TABLE hdb_catalog.hdb_permission (
669 table_schema name NOT NULL,
670 table_name name NOT NULL,
671 role_name text NOT NULL,
672 perm_type text NOT NULL,
673 perm_def jsonb NOT NULL,
674 comment text,
675 is_system_defined boolean DEFAULT false,
676 CONSTRAINT hdb_permission_perm_type_check CHECK ((perm_type = ANY (ARRAY['insert'::text, 'select'::text, 'update'::text, 'delete'::text])))
677);
678
679
680ALTER TABLE hdb_catalog.hdb_permission OWNER TO postgres;
681
682--
683-- Name: hdb_permission_agg; Type: VIEW; Schema: hdb_catalog; Owner: postgres
684--
685
686CREATE VIEW hdb_catalog.hdb_permission_agg AS
687 SELECT hdb_permission.table_schema,
688 hdb_permission.table_name,
689 hdb_permission.role_name,
690 json_object_agg(hdb_permission.perm_type, hdb_permission.perm_def) AS permissions
691 FROM hdb_catalog.hdb_permission
692 GROUP BY hdb_permission.table_schema, hdb_permission.table_name, hdb_permission.role_name;
693
694
695ALTER TABLE hdb_catalog.hdb_permission_agg OWNER TO postgres;
696
697--
698-- Name: hdb_primary_key; Type: VIEW; Schema: hdb_catalog; Owner: postgres
699--
700
701CREATE VIEW hdb_catalog.hdb_primary_key AS
702 SELECT tc.table_schema,
703 tc.table_name,
704 tc.constraint_name,
705 json_agg(constraint_column_usage.column_name) AS columns
706 FROM (information_schema.table_constraints tc
707 JOIN ( SELECT x.tblschema AS table_schema,
708 x.tblname AS table_name,
709 x.colname AS column_name,
710 x.cstrname AS constraint_name
711 FROM ( SELECT DISTINCT nr.nspname,
712 r.relname,
713 a.attname,
714 c.conname
715 FROM pg_namespace nr,
716 pg_class r,
717 pg_attribute a,
718 pg_depend d,
719 pg_namespace nc,
720 pg_constraint c
721 WHERE ((nr.oid = r.relnamespace) AND (r.oid = a.attrelid) AND (d.refclassid = ('pg_class'::regclass)::oid) AND (d.refobjid = r.oid) AND (d.refobjsubid = a.attnum) AND (d.classid = ('pg_constraint'::regclass)::oid) AND (d.objid = c.oid) AND (c.connamespace = nc.oid) AND (c.contype = 'c'::"char") AND (r.relkind = ANY (ARRAY['r'::"char", 'p'::"char"])) AND (NOT a.attisdropped))
722 UNION ALL
723 SELECT nr.nspname,
724 r.relname,
725 a.attname,
726 c.conname
727 FROM pg_namespace nr,
728 pg_class r,
729 pg_attribute a,
730 pg_namespace nc,
731 pg_constraint c
732 WHERE ((nr.oid = r.relnamespace) AND (r.oid = a.attrelid) AND (nc.oid = c.connamespace) AND (r.oid =
733 CASE c.contype
734 WHEN 'f'::"char" THEN c.confrelid
735 ELSE c.conrelid
736 END) AND (a.attnum = ANY (
737 CASE c.contype
738 WHEN 'f'::"char" THEN c.confkey
739 ELSE c.conkey
740 END)) AND (NOT a.attisdropped) AND (c.contype = ANY (ARRAY['p'::"char", 'u'::"char", 'f'::"char"])) AND (r.relkind = ANY (ARRAY['r'::"char", 'p'::"char"])))) x(tblschema, tblname, colname, cstrname)) constraint_column_usage ON ((((tc.constraint_name)::text = (constraint_column_usage.constraint_name)::text) AND ((tc.table_schema)::text = (constraint_column_usage.table_schema)::text) AND ((tc.table_name)::text = (constraint_column_usage.table_name)::text))))
741 WHERE ((tc.constraint_type)::text = 'PRIMARY KEY'::text)
742 GROUP BY tc.table_schema, tc.table_name, tc.constraint_name;
743
744
745ALTER TABLE hdb_catalog.hdb_primary_key OWNER TO postgres;
746
747--
748-- Name: hdb_query_collection; Type: TABLE; Schema: hdb_catalog; Owner: postgres
749--
750
751CREATE TABLE hdb_catalog.hdb_query_collection (
752 collection_name text NOT NULL,
753 collection_defn jsonb NOT NULL,
754 comment text,
755 is_system_defined boolean DEFAULT false
756);
757
758
759ALTER TABLE hdb_catalog.hdb_query_collection OWNER TO postgres;
760
761--
762-- Name: hdb_relationship; Type: TABLE; Schema: hdb_catalog; Owner: postgres
763--
764
765CREATE TABLE hdb_catalog.hdb_relationship (
766 table_schema name NOT NULL,
767 table_name name NOT NULL,
768 rel_name text NOT NULL,
769 rel_type text,
770 rel_def jsonb NOT NULL,
771 comment text,
772 is_system_defined boolean DEFAULT false,
773 CONSTRAINT hdb_relationship_rel_type_check CHECK ((rel_type = ANY (ARRAY['object'::text, 'array'::text])))
774);
775
776
777ALTER TABLE hdb_catalog.hdb_relationship OWNER TO postgres;
778
779--
780-- Name: hdb_role; Type: VIEW; Schema: hdb_catalog; Owner: postgres
781--
782
783CREATE VIEW hdb_catalog.hdb_role AS
784 SELECT DISTINCT q.role_name
785 FROM ( SELECT hdb_permission.role_name
786 FROM hdb_catalog.hdb_permission
787 UNION ALL
788 SELECT hdb_action_permission.role_name
789 FROM hdb_catalog.hdb_action_permission) q;
790
791
792ALTER TABLE hdb_catalog.hdb_role OWNER TO postgres;
793
794--
795-- Name: hdb_schema_update_event; Type: TABLE; Schema: hdb_catalog; Owner: postgres
796--
797
798CREATE TABLE hdb_catalog.hdb_schema_update_event (
799 instance_id uuid NOT NULL,
800 occurred_at timestamp with time zone DEFAULT now() NOT NULL,
801 invalidations json NOT NULL
802);
803
804
805ALTER TABLE hdb_catalog.hdb_schema_update_event OWNER TO postgres;
806
807--
808-- Name: hdb_table; Type: TABLE; Schema: hdb_catalog; Owner: postgres
809--
810
811CREATE TABLE hdb_catalog.hdb_table (
812 table_schema name NOT NULL,
813 table_name name NOT NULL,
814 configuration jsonb,
815 is_system_defined boolean DEFAULT false,
816 is_enum boolean DEFAULT false NOT NULL
817);
818
819
820ALTER TABLE hdb_catalog.hdb_table OWNER TO postgres;
821
822--
823-- Name: hdb_table_info_agg; Type: VIEW; Schema: hdb_catalog; Owner: postgres
824--
825
826CREATE VIEW hdb_catalog.hdb_table_info_agg AS
827 SELECT schema.nspname AS table_schema,
828 "table".relname AS table_name,
829 jsonb_build_object('oid', ("table".oid)::integer, 'columns', COALESCE(columns.info, '[]'::jsonb), 'primary_key', primary_key.info, 'unique_constraints', COALESCE(unique_constraints.info, '[]'::jsonb), 'foreign_keys', COALESCE(foreign_key_constraints.info, '[]'::jsonb), 'view_info',
830 CASE "table".relkind
831 WHEN 'v'::"char" THEN jsonb_build_object('is_updatable', ((pg_relation_is_updatable(("table".oid)::regclass, true) & 4) = 4), 'is_insertable', ((pg_relation_is_updatable(("table".oid)::regclass, true) & 8) = 8), 'is_deletable', ((pg_relation_is_updatable(("table".oid)::regclass, true) & 16) = 16))
832 ELSE NULL::jsonb
833 END, 'description', description.description) AS info
834 FROM ((((((pg_class "table"
835 JOIN pg_namespace schema ON ((schema.oid = "table".relnamespace)))
836 LEFT JOIN pg_description description ON (((description.classoid = ('pg_class'::regclass)::oid) AND (description.objoid = "table".oid) AND (description.objsubid = 0))))
837 LEFT JOIN LATERAL ( SELECT jsonb_agg(jsonb_build_object('name', "column".attname, 'position', "column".attnum, 'type', COALESCE(base_type.typname, type.typname), 'is_nullable', (NOT "column".attnotnull), 'description', col_description("table".oid, ("column".attnum)::integer))) AS info
838 FROM ((pg_attribute "column"
839 LEFT JOIN pg_type type ON ((type.oid = "column".atttypid)))
840 LEFT JOIN pg_type base_type ON (((type.typtype = 'd'::"char") AND (base_type.oid = type.typbasetype))))
841 WHERE (("column".attrelid = "table".oid) AND ("column".attnum > 0) AND (NOT "column".attisdropped))) columns ON (true))
842 LEFT JOIN LATERAL ( SELECT jsonb_build_object('constraint', jsonb_build_object('name', class.relname, 'oid', (class.oid)::integer), 'columns', COALESCE(columns_1.info, '[]'::jsonb)) AS info
843 FROM ((pg_index index
844 JOIN pg_class class ON ((class.oid = index.indexrelid)))
845 LEFT JOIN LATERAL ( SELECT jsonb_agg("column".attname) AS info
846 FROM pg_attribute "column"
847 WHERE (("column".attrelid = "table".oid) AND ("column".attnum = ANY ((index.indkey)::smallint[])))) columns_1 ON (true))
848 WHERE ((index.indrelid = "table".oid) AND index.indisprimary)) primary_key ON (true))
849 LEFT JOIN LATERAL ( SELECT jsonb_agg(jsonb_build_object('name', class.relname, 'oid', (class.oid)::integer)) AS info
850 FROM (pg_index index
851 JOIN pg_class class ON ((class.oid = index.indexrelid)))
852 WHERE ((index.indrelid = "table".oid) AND index.indisunique AND (NOT index.indisprimary))) unique_constraints ON (true))
853 LEFT JOIN LATERAL ( SELECT jsonb_agg(jsonb_build_object('constraint', jsonb_build_object('name', foreign_key.constraint_name, 'oid', foreign_key.constraint_oid), 'columns', foreign_key.columns, 'foreign_table', jsonb_build_object('schema', foreign_key.ref_table_table_schema, 'name', foreign_key.ref_table), 'foreign_columns', foreign_key.ref_columns)) AS info
854 FROM hdb_catalog.hdb_foreign_key_constraint foreign_key
855 WHERE ((foreign_key.table_schema = schema.nspname) AND (foreign_key.table_name = "table".relname))) foreign_key_constraints ON (true))
856 WHERE ("table".relkind = ANY (ARRAY['r'::"char", 't'::"char", 'v'::"char", 'm'::"char", 'f'::"char", 'p'::"char"]));
857
858
859ALTER TABLE hdb_catalog.hdb_table_info_agg OWNER TO postgres;
860
861--
862-- Name: hdb_unique_constraint; Type: VIEW; Schema: hdb_catalog; Owner: postgres
863--
864
865CREATE VIEW hdb_catalog.hdb_unique_constraint AS
866 SELECT tc.table_name,
867 tc.constraint_schema AS table_schema,
868 tc.constraint_name,
869 json_agg(kcu.column_name) AS columns
870 FROM (information_schema.table_constraints tc
871 JOIN information_schema.key_column_usage kcu USING (constraint_schema, constraint_name))
872 WHERE ((tc.constraint_type)::text = 'UNIQUE'::text)
873 GROUP BY tc.table_name, tc.constraint_schema, tc.constraint_name;
874
875
876ALTER TABLE hdb_catalog.hdb_unique_constraint OWNER TO postgres;
877
878--
879-- Name: hdb_version; Type: TABLE; Schema: hdb_catalog; Owner: postgres
880--
881
882CREATE TABLE hdb_catalog.hdb_version (
883 hasura_uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
884 version text NOT NULL,
885 upgraded_on timestamp with time zone NOT NULL,
886 cli_state jsonb DEFAULT '{}'::jsonb NOT NULL,
887 console_state jsonb DEFAULT '{}'::jsonb NOT NULL
888);
889
890
891ALTER TABLE hdb_catalog.hdb_version OWNER TO postgres;
892
893--
894-- Name: migration_settings; Type: TABLE; Schema: hdb_catalog; Owner: postgres
895--
896
897CREATE TABLE hdb_catalog.migration_settings (
898 setting text NOT NULL,
899 value text NOT NULL
900);
901
902
903ALTER TABLE hdb_catalog.migration_settings OWNER TO postgres;
904
905--
906-- Name: remote_schemas; Type: TABLE; Schema: hdb_catalog; Owner: postgres
907--
908
909CREATE TABLE hdb_catalog.remote_schemas (
910 id bigint NOT NULL,
911 name text,
912 definition json,
913 comment text
914);
915
916
917ALTER TABLE hdb_catalog.remote_schemas OWNER TO postgres;
918
919--
920-- Name: remote_schemas_id_seq; Type: SEQUENCE; Schema: hdb_catalog; Owner: postgres
921--
922
923CREATE SEQUENCE hdb_catalog.remote_schemas_id_seq
924 START WITH 1
925 INCREMENT BY 1
926 NO MINVALUE
927 NO MAXVALUE
928 CACHE 1;
929
930
931ALTER TABLE hdb_catalog.remote_schemas_id_seq OWNER TO postgres;
932
933--
934-- Name: remote_schemas_id_seq; Type: SEQUENCE OWNED BY; Schema: hdb_catalog; Owner: postgres
935--
936
937ALTER SEQUENCE hdb_catalog.remote_schemas_id_seq OWNED BY hdb_catalog.remote_schemas.id;
938
939
940--
941-- Name: schema_migrations; Type: TABLE; Schema: hdb_catalog; Owner: postgres
942--
943
944CREATE TABLE hdb_catalog.schema_migrations (
945 version bigint NOT NULL,
946 dirty boolean NOT NULL
947);
948
949
950ALTER TABLE hdb_catalog.schema_migrations OWNER TO postgres;
951
952--
953-- Name: Auto; Type: TABLE; Schema: public; Owner: postgres
954--
955
956CREATE TABLE public."Auto" (
957 mark text NOT NULL,
958 model text NOT NULL,
959 year integer NOT NULL,
960 plate text NOT NULL,
961 vin text NOT NULL,
962 "bodyNumber" text NOT NULL,
963 "registrationDate" date NOT NULL,
964 "registrationPlace" text NOT NULL,
965 color text NOT NULL,
966 owner text NOT NULL,
967 "ownerName" text,
968 "ownerAddress" text,
969 "passportSeries" text,
970 "passportNumber" text,
971 "passportIssueDate" date,
972 "passportIssuer" text,
973 "entityName" text,
974 "entityInn" text,
975 "entityOgrn" text,
976 "licenseNumber" text,
977 "licenseEntityId" integer,
978 "licenseDate" date,
979 "licenseExpirationDate" date,
980 "isRemoved" boolean DEFAULT false NOT NULL,
981 created_at timestamp with time zone DEFAULT now(),
982 updated_at timestamp with time zone DEFAULT now(),
983 "driverId" uuid,
984 "organizationId" uuid NOT NULL,
985 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
986 category text NOT NULL,
987 "isTaxi" boolean DEFAULT false,
988 "contractId" uuid
989);
990
991
992ALTER TABLE public."Auto" OWNER TO postgres;
993
994--
995-- Name: AutoGto; Type: TABLE; Schema: public; Owner: postgres
996--
997
998CREATE TABLE public."AutoGto" (
999 id integer NOT NULL,
1000 number text NOT NULL,
1001 "issueDate" date NOT NULL,
1002 "expirationDate" date NOT NULL,
1003 "forTaxi" boolean NOT NULL,
1004 "autoId" integer NOT NULL,
1005 "scanFileId" integer NOT NULL,
1006 "isRemoved" boolean DEFAULT false NOT NULL,
1007 created_at timestamp with time zone DEFAULT now(),
1008 updated_at timestamp with time zone DEFAULT now()
1009);
1010
1011
1012ALTER TABLE public."AutoGto" OWNER TO postgres;
1013
1014--
1015-- Name: AutoInsurance; Type: TABLE; Schema: public; Owner: postgres
1016--
1017
1018CREATE TABLE public."AutoInsurance" (
1019 id integer NOT NULL,
1020 company text NOT NULL,
1021 "issueDate" date NOT NULL,
1022 "expirationDate" date NOT NULL,
1023 "scanFileId" integer NOT NULL,
1024 "autoId" integer NOT NULL,
1025 "isRemoved" boolean DEFAULT false NOT NULL,
1026 created_at timestamp with time zone DEFAULT now(),
1027 updated_at timestamp with time zone DEFAULT now()
1028);
1029
1030
1031ALTER TABLE public."AutoInsurance" OWNER TO postgres;
1032
1033--
1034-- Name: AutoSts; Type: TABLE; Schema: public; Owner: postgres
1035--
1036
1037CREATE TABLE public."AutoSts" (
1038 id integer NOT NULL,
1039 number text NOT NULL,
1040 "expirationDate" date NOT NULL,
1041 "scanFileId" integer NOT NULL,
1042 "autoId" integer NOT NULL,
1043 "isRemoved" boolean DEFAULT false NOT NULL,
1044 created_at timestamp with time zone DEFAULT now(),
1045 updated_at timestamp with time zone DEFAULT now()
1046);
1047
1048
1049ALTER TABLE public."AutoSts" OWNER TO postgres;
1050
1051--
1052-- Name: City; Type: TABLE; Schema: public; Owner: postgres
1053--
1054
1055CREATE TABLE public."City" (
1056 name text NOT NULL,
1057 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1058 created_at timestamp with time zone DEFAULT now() NOT NULL,
1059 "isRemoved" boolean DEFAULT false NOT NULL,
1060 "organizationId" uuid
1061);
1062
1063
1064ALTER TABLE public."City" OWNER TO postgres;
1065
1066--
1067-- Name: Document; Type: TABLE; Schema: public; Owner: postgres
1068--
1069
1070CREATE TABLE public."Document" (
1071 "organizationId" uuid NOT NULL,
1072 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1073 name text,
1074 event text,
1075 "isRemoved" boolean DEFAULT false NOT NULL,
1076 created_at timestamp with time zone DEFAULT now(),
1077 updated_at timestamp with time zone DEFAULT now(),
1078 "fileId" uuid,
1079 "contractType" text,
1080 prolongation boolean DEFAULT false,
1081 "isDefault" boolean DEFAULT false,
1082 "cityId" uuid,
1083 "inspectionType" text
1084);
1085
1086
1087ALTER TABLE public."Document" OWNER TO postgres;
1088
1089--
1090-- Name: DriverCertificate; Type: TABLE; Schema: public; Owner: postgres
1091--
1092
1093CREATE TABLE public."DriverCertificate" (
1094 id integer NOT NULL,
1095 number text NOT NULL,
1096 "issueDate" date NOT NULL,
1097 "expirationDate" date NOT NULL,
1098 experience date NOT NULL,
1099 "scanFileId" integer NOT NULL,
1100 categories jsonb NOT NULL,
1101 "driverId" integer NOT NULL,
1102 "isRemoved" boolean DEFAULT false NOT NULL,
1103 created_at timestamp with time zone DEFAULT now(),
1104 updated_at timestamp with time zone DEFAULT now()
1105);
1106
1107
1108ALTER TABLE public."DriverCertificate" OWNER TO postgres;
1109
1110--
1111-- Name: Entity; Type: TABLE; Schema: public; Owner: postgres
1112--
1113
1114CREATE TABLE public."Entity" (
1115 name text NOT NULL,
1116 "legalName" text NOT NULL,
1117 "isRemoved" boolean DEFAULT false NOT NULL,
1118 created_at timestamp with time zone DEFAULT now(),
1119 updated_at timestamp with time zone DEFAULT now(),
1120 "organizationId" uuid DEFAULT public.gen_random_uuid() NOT NULL,
1121 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1122 "intermediaryId" uuid,
1123 kpp text,
1124 "bossName" text,
1125 "bossPosition" text,
1126 inn text,
1127 ogrn text,
1128 okpo text,
1129 okved text,
1130 address text,
1131 "fullAddress" text,
1132 type text,
1133 bic text,
1134 "bankAccount" text,
1135 email text,
1136 phone text,
1137 opf text,
1138 "fullOpf" text,
1139 "lkIsActive" boolean DEFAULT false NOT NULL,
1140 "actualAddress" text,
1141 "bossDocument" text
1142);
1143
1144
1145ALTER TABLE public."Entity" OWNER TO postgres;
1146
1147--
1148-- Name: EntityContract; Type: TABLE; Schema: public; Owner: postgres
1149--
1150
1151CREATE TABLE public."EntityContract" (
1152 number numeric NOT NULL,
1153 type text NOT NULL,
1154 "paymentInterval" integer DEFAULT 1 NOT NULL,
1155 "paymentSum" integer,
1156 "workingHoursMode" text DEFAULT 'full'::text NOT NULL,
1157 "paymentMethod" text DEFAULT 'cash'::text NOT NULL,
1158 "isRemoved" boolean DEFAULT false NOT NULL,
1159 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1160 created_at timestamp with time zone DEFAULT now() NOT NULL,
1161 updated_at timestamp with time zone DEFAULT now() NOT NULL,
1162 date date,
1163 "entityId" uuid NOT NULL,
1164 "inspectionType" text DEFAULT 'both'::text,
1165 "organizationId" uuid,
1166 "minPenalty" integer DEFAULT 0,
1167 penalty double precision DEFAULT 0.5,
1168 "isManualSum" boolean DEFAULT false,
1169 file text,
1170 prolongation boolean DEFAULT false,
1171 "inspectionLocation" text,
1172 "frozenBalance" integer DEFAULT 0,
1173 balance integer DEFAULT 0,
1174 "documentIsGenerated" boolean DEFAULT false NOT NULL
1175);
1176
1177
1178ALTER TABLE public."EntityContract" OWNER TO postgres;
1179
1180--
1181-- Name: EntityContractChanges; Type: TABLE; Schema: public; Owner: postgres
1182--
1183
1184CREATE TABLE public."EntityContractChanges" (
1185 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1186 "contractId" uuid NOT NULL,
1187 type text NOT NULL,
1188 payload jsonb NOT NULL,
1189 created_at timestamp with time zone DEFAULT now() NOT NULL,
1190 updated_at timestamp with time zone DEFAULT now()
1191);
1192
1193
1194ALTER TABLE public."EntityContractChanges" OWNER TO postgres;
1195
1196--
1197-- Name: Expense; Type: TABLE; Schema: public; Owner: postgres
1198--
1199
1200CREATE TABLE public."Expense" (
1201 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1202 amount numeric,
1203 comment text,
1204 "paymentType" text,
1205 created_at timestamp with time zone DEFAULT now() NOT NULL,
1206 updated_at timestamp with time zone DEFAULT now() NOT NULL,
1207 "organizationId" uuid NOT NULL,
1208 "isRemoved" boolean DEFAULT false NOT NULL,
1209 "creatorId" uuid,
1210 "officeId" uuid
1211);
1212
1213
1214ALTER TABLE public."Expense" OWNER TO postgres;
1215
1216--
1217-- Name: File; Type: TABLE; Schema: public; Owner: postgres
1218--
1219
1220CREATE TABLE public."File" (
1221 name text,
1222 type text NOT NULL,
1223 created_at timestamp with time zone DEFAULT now() NOT NULL,
1224 "isRemoved" boolean DEFAULT false NOT NULL,
1225 path text NOT NULL,
1226 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1227 "driverId" uuid,
1228 sort numeric DEFAULT 100000 NOT NULL,
1229 url text,
1230 "contractId" uuid,
1231 "inspectionId" uuid
1232);
1233
1234
1235ALTER TABLE public."File" OWNER TO postgres;
1236
1237--
1238-- Name: Inspection; Type: TABLE; Schema: public; Owner: postgres
1239--
1240
1241CREATE TABLE public."Inspection" (
1242 created_at timestamp with time zone DEFAULT now() NOT NULL,
1243 updated_at timestamp with time zone DEFAULT now() NOT NULL,
1244 date timestamp with time zone DEFAULT now() NOT NULL,
1245 complaints text,
1246 "visualInspection" text,
1247 temperature text,
1248 "arterialPressure" text,
1249 pulse text,
1250 "alcoholDetected" text,
1251 conclusion text,
1252 "instructionType" text,
1253 "instructionDescription" text,
1254 "autoPlate" text,
1255 "driverName" text,
1256 "driverBirthdate" date,
1257 "autoMark" text,
1258 "departureDate" timestamp with time zone,
1259 "arrivalDate" timestamp with time zone,
1260 "autoTechnicalCondition" text,
1261 "autoSpeedometer" text,
1262 "waysheetIssueDate" timestamp with time zone,
1263 comment text,
1264 "driverPhone" text,
1265 "driverGender" text DEFAULT 'man'::text NOT NULL,
1266 "organizationId" uuid NOT NULL,
1267 "isRemoved" boolean DEFAULT false NOT NULL,
1268 "waysheetNumber" numeric DEFAULT 0 NOT NULL,
1269 "medicalDate" timestamp with time zone,
1270 "instructionDate" timestamp with time zone,
1271 "arrivalsDate" timestamp with time zone,
1272 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1273 "medicId" uuid,
1274 "technicianId" uuid,
1275 "creatorId" uuid,
1276 "driverId" uuid,
1277 "autoId" uuid,
1278 "fuelRemaining" text,
1279 "medicalDateAfter" timestamp with time zone,
1280 "complaintsAfter" text,
1281 "visualInspectionAfter" text,
1282 "temperatureAfter" text,
1283 "arterialPressureAfter" text,
1284 "pulseAfter" text,
1285 "alcoholDetectedAfter" text,
1286 "conclusionAfter" text,
1287 "autoSpeedometerAfter" text,
1288 "autoTechnicalConditionAfter" text,
1289 "fuelRemainingAfter" text,
1290 "fuelMark" text
1291);
1292
1293
1294ALTER TABLE public."Inspection" OWNER TO postgres;
1295
1296--
1297-- Name: Intermediary; Type: TABLE; Schema: public; Owner: postgres
1298--
1299
1300CREATE TABLE public."Intermediary" (
1301 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1302 "organizationId" uuid NOT NULL,
1303 name text NOT NULL,
1304 "isRemoved" boolean DEFAULT false NOT NULL,
1305 created_at timestamp with time zone DEFAULT now() NOT NULL,
1306 updated_at timestamp with time zone DEFAULT now() NOT NULL
1307);
1308
1309
1310ALTER TABLE public."Intermediary" OWNER TO postgres;
1311
1312--
1313-- Name: Log; Type: TABLE; Schema: public; Owner: postgres
1314--
1315
1316CREATE TABLE public."Log" (
1317 "organizationId" uuid,
1318 key text NOT NULL,
1319 content text NOT NULL,
1320 "isRemoved" boolean DEFAULT false NOT NULL,
1321 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1322 created_at timestamp with time zone DEFAULT now() NOT NULL
1323);
1324
1325
1326ALTER TABLE public."Log" OWNER TO postgres;
1327
1328--
1329-- Name: Office; Type: TABLE; Schema: public; Owner: postgres
1330--
1331
1332CREATE TABLE public."Office" (
1333 name text NOT NULL,
1334 address text,
1335 created_at timestamp with time zone DEFAULT now() NOT NULL,
1336 updated_at timestamp with time zone DEFAULT now() NOT NULL,
1337 "isRemoved" boolean DEFAULT false NOT NULL,
1338 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1339 "organizationId" uuid NOT NULL,
1340 "cityId" uuid
1341);
1342
1343
1344ALTER TABLE public."Office" OWNER TO postgres;
1345
1346--
1347-- Name: OnlinePayment; Type: TABLE; Schema: public; Owner: postgres
1348--
1349
1350CREATE TABLE public."OnlinePayment" (
1351 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1352 sum numeric NOT NULL,
1353 "organizationId" uuid NOT NULL,
1354 created_at timestamp with time zone DEFAULT now() NOT NULL,
1355 updated_at timestamp with time zone DEFAULT now() NOT NULL,
1356 "creatorId" uuid,
1357 "isPaid" boolean DEFAULT false,
1358 "paymentDate" timestamp with time zone,
1359 type text NOT NULL,
1360 payload jsonb,
1361 "paymentId" text NOT NULL,
1362 "contractId" uuid
1363);
1364
1365
1366ALTER TABLE public."OnlinePayment" OWNER TO postgres;
1367
1368--
1369-- Name: Organization; Type: TABLE; Schema: public; Owner: postgres
1370--
1371
1372CREATE TABLE public."Organization" (
1373 name text NOT NULL,
1374 "legalName" text NOT NULL,
1375 balance integer NOT NULL,
1376 "lastPaymentDate" date,
1377 created_at timestamp with time zone DEFAULT now() NOT NULL,
1378 updated_at timestamp with time zone DEFAULT now() NOT NULL,
1379 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1380 kpp text,
1381 inn text,
1382 ogrn text,
1383 bic text,
1384 email text,
1385 "bankAccount" text,
1386 phone text,
1387 "bossName" text,
1388 "actualAddress" text,
1389 "bossDocument" text,
1390 address text
1391);
1392
1393
1394ALTER TABLE public."Organization" OWNER TO postgres;
1395
1396--
1397-- Name: PaidMonth; Type: TABLE; Schema: public; Owner: postgres
1398--
1399
1400CREATE TABLE public."PaidMonth" (
1401 "isRemoved" boolean DEFAULT false NOT NULL,
1402 "paymentId" uuid,
1403 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1404 created_at timestamp with time zone DEFAULT now() NOT NULL,
1405 month date,
1406 "contractId" uuid,
1407 "isMoneyWithdrawn" boolean DEFAULT false
1408);
1409
1410
1411ALTER TABLE public."PaidMonth" OWNER TO postgres;
1412
1413--
1414-- Name: Payment; Type: TABLE; Schema: public; Owner: postgres
1415--
1416
1417CREATE TABLE public."Payment" (
1418 "organizationId" uuid NOT NULL,
1419 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1420 created_at timestamp with time zone DEFAULT now() NOT NULL,
1421 updated_at timestamp with time zone DEFAULT now() NOT NULL,
1422 "tariffId" uuid NOT NULL,
1423 "isRemoved" boolean DEFAULT false NOT NULL,
1424 "creatorId" uuid,
1425 "contractId" uuid,
1426 sum numeric DEFAULT 0,
1427 date timestamp with time zone DEFAULT now(),
1428 "isFixed" boolean DEFAULT true,
1429 "bankOperationId" text
1430);
1431
1432
1433ALTER TABLE public."Payment" OWNER TO postgres;
1434
1435--
1436-- Name: Role; Type: TABLE; Schema: public; Owner: postgres
1437--
1438
1439CREATE TABLE public."Role" (
1440 name text NOT NULL,
1441 "isRemoved" boolean DEFAULT false NOT NULL,
1442 created_at timestamp with time zone DEFAULT now(),
1443 updated_at timestamp with time zone DEFAULT now(),
1444 "organizationId" uuid NOT NULL,
1445 id uuid DEFAULT public.gen_random_uuid() NOT NULL
1446);
1447
1448
1449ALTER TABLE public."Role" OWNER TO postgres;
1450
1451--
1452-- Name: Settings; Type: TABLE; Schema: public; Owner: postgres
1453--
1454
1455CREATE TABLE public."Settings" (
1456 "isRemoved" boolean DEFAULT false NOT NULL,
1457 "paymentPeriodStart" integer DEFAULT 25 NOT NULL,
1458 "paymentPeriodEnd" integer DEFAULT 5 NOT NULL,
1459 "organizationId" uuid NOT NULL
1460);
1461
1462
1463ALTER TABLE public."Settings" OWNER TO postgres;
1464
1465--
1466-- Name: Tariff; Type: TABLE; Schema: public; Owner: postgres
1467--
1468
1469CREATE TABLE public."Tariff" (
1470 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1471 "organizationId" uuid NOT NULL,
1472 event text NOT NULL,
1473 payment text,
1474 required boolean DEFAULT false NOT NULL,
1475 "default" integer DEFAULT 0 NOT NULL,
1476 "categoryB" integer,
1477 "categoryC" integer,
1478 "categoryD" integer,
1479 "categoryE" integer,
1480 "isRemoved" boolean DEFAULT false NOT NULL,
1481 inspection text,
1482 driver integer,
1483 value integer,
1484 name text,
1485 "inspectionLocation" text,
1486 "isGreaterThan50" boolean
1487);
1488
1489
1490ALTER TABLE public."Tariff" OWNER TO postgres;
1491
1492--
1493-- Name: User; Type: TABLE; Schema: public; Owner: postgres
1494--
1495
1496CREATE TABLE public."User" (
1497 name text NOT NULL,
1498 email text NOT NULL,
1499 "passwordHash" text NOT NULL,
1500 "passwordSalt" text NOT NULL,
1501 "isBlocked" boolean DEFAULT false NOT NULL,
1502 "isRemoved" boolean DEFAULT false NOT NULL,
1503 created_at timestamp with time zone DEFAULT now(),
1504 updated_at timestamp with time zone DEFAULT now(),
1505 "organizationId" uuid NOT NULL,
1506 id uuid DEFAULT public.gen_random_uuid() NOT NULL,
1507 role text NOT NULL,
1508 "officeId" uuid,
1509 "entityId" uuid
1510);
1511
1512
1513ALTER TABLE public."User" OWNER TO postgres;
1514
1515--
1516-- Name: TABLE "User"; Type: COMMENT; Schema: public; Owner: postgres
1517--
1518
1519COMMENT ON TABLE public."User" IS 'The Users table';
1520
1521
1522--
1523-- Name: autGto_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
1524--
1525
1526CREATE SEQUENCE public."autGto_id_seq"
1527 AS integer
1528 START WITH 1
1529 INCREMENT BY 1
1530 NO MINVALUE
1531 NO MAXVALUE
1532 CACHE 1;
1533
1534
1535ALTER TABLE public."autGto_id_seq" OWNER TO postgres;
1536
1537--
1538-- Name: autGto_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
1539--
1540
1541ALTER SEQUENCE public."autGto_id_seq" OWNED BY public."AutoGto".id;
1542
1543
1544--
1545-- Name: autoInsurance_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
1546--
1547
1548CREATE SEQUENCE public."autoInsurance_id_seq"
1549 AS integer
1550 START WITH 1
1551 INCREMENT BY 1
1552 NO MINVALUE
1553 NO MAXVALUE
1554 CACHE 1;
1555
1556
1557ALTER TABLE public."autoInsurance_id_seq" OWNER TO postgres;
1558
1559--
1560-- Name: autoInsurance_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
1561--
1562
1563ALTER SEQUENCE public."autoInsurance_id_seq" OWNED BY public."AutoInsurance".id;
1564
1565
1566--
1567-- Name: autoSts_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
1568--
1569
1570CREATE SEQUENCE public."autoSts_id_seq"
1571 AS integer
1572 START WITH 1
1573 INCREMENT BY 1
1574 NO MINVALUE
1575 NO MAXVALUE
1576 CACHE 1;
1577
1578
1579ALTER TABLE public."autoSts_id_seq" OWNER TO postgres;
1580
1581--
1582-- Name: autoSts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
1583--
1584
1585ALTER SEQUENCE public."autoSts_id_seq" OWNED BY public."AutoSts".id;
1586
1587
1588--
1589-- Name: driverCertificates_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
1590--
1591
1592CREATE SEQUENCE public."driverCertificates_id_seq"
1593 AS integer
1594 START WITH 1
1595 INCREMENT BY 1
1596 NO MINVALUE
1597 NO MAXVALUE
1598 CACHE 1;
1599
1600
1601ALTER TABLE public."driverCertificates_id_seq" OWNER TO postgres;
1602
1603--
1604-- Name: driverCertificates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
1605--
1606
1607ALTER SEQUENCE public."driverCertificates_id_seq" OWNED BY public."DriverCertificate".id;
1608
1609
1610--
1611-- Name: remote_schemas id; Type: DEFAULT; Schema: hdb_catalog; Owner: postgres
1612--
1613
1614ALTER TABLE ONLY hdb_catalog.remote_schemas ALTER COLUMN id SET DEFAULT nextval('hdb_catalog.remote_schemas_id_seq'::regclass);
1615
1616
1617--
1618-- Name: AutoGto id; Type: DEFAULT; Schema: public; Owner: postgres
1619--
1620
1621ALTER TABLE ONLY public."AutoGto" ALTER COLUMN id SET DEFAULT nextval('public."autGto_id_seq"'::regclass);
1622
1623
1624--
1625-- Name: AutoInsurance id; Type: DEFAULT; Schema: public; Owner: postgres
1626--
1627
1628ALTER TABLE ONLY public."AutoInsurance" ALTER COLUMN id SET DEFAULT nextval('public."autoInsurance_id_seq"'::regclass);
1629
1630
1631--
1632-- Name: AutoSts id; Type: DEFAULT; Schema: public; Owner: postgres
1633--
1634
1635ALTER TABLE ONLY public."AutoSts" ALTER COLUMN id SET DEFAULT nextval('public."autoSts_id_seq"'::regclass);
1636
1637
1638--
1639-- Name: DriverCertificate id; Type: DEFAULT; Schema: public; Owner: postgres
1640--
1641
1642ALTER TABLE ONLY public."DriverCertificate" ALTER COLUMN id SET DEFAULT nextval('public."driverCertificates_id_seq"'::regclass);
1643
1644
1645--
1646-- Name: event_invocation_logs event_invocation_logs_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1647--
1648
1649ALTER TABLE ONLY hdb_catalog.event_invocation_logs
1650 ADD CONSTRAINT event_invocation_logs_pkey PRIMARY KEY (id);
1651
1652
1653--
1654-- Name: event_log event_log_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1655--
1656
1657ALTER TABLE ONLY hdb_catalog.event_log
1658 ADD CONSTRAINT event_log_pkey PRIMARY KEY (id);
1659
1660
1661--
1662-- Name: event_triggers event_triggers_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1663--
1664
1665ALTER TABLE ONLY hdb_catalog.event_triggers
1666 ADD CONSTRAINT event_triggers_pkey PRIMARY KEY (name);
1667
1668
1669--
1670-- Name: hdb_action_log hdb_action_log_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1671--
1672
1673ALTER TABLE ONLY hdb_catalog.hdb_action_log
1674 ADD CONSTRAINT hdb_action_log_pkey PRIMARY KEY (id);
1675
1676
1677--
1678-- Name: hdb_action_permission hdb_action_permission_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1679--
1680
1681ALTER TABLE ONLY hdb_catalog.hdb_action_permission
1682 ADD CONSTRAINT hdb_action_permission_pkey PRIMARY KEY (action_name, role_name);
1683
1684
1685--
1686-- Name: hdb_action hdb_action_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1687--
1688
1689ALTER TABLE ONLY hdb_catalog.hdb_action
1690 ADD CONSTRAINT hdb_action_pkey PRIMARY KEY (action_name);
1691
1692
1693--
1694-- Name: hdb_allowlist hdb_allowlist_collection_name_key; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1695--
1696
1697ALTER TABLE ONLY hdb_catalog.hdb_allowlist
1698 ADD CONSTRAINT hdb_allowlist_collection_name_key UNIQUE (collection_name);
1699
1700
1701--
1702-- Name: hdb_computed_field hdb_computed_field_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1703--
1704
1705ALTER TABLE ONLY hdb_catalog.hdb_computed_field
1706 ADD CONSTRAINT hdb_computed_field_pkey PRIMARY KEY (table_schema, table_name, computed_field_name);
1707
1708
1709--
1710-- Name: hdb_function hdb_function_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1711--
1712
1713ALTER TABLE ONLY hdb_catalog.hdb_function
1714 ADD CONSTRAINT hdb_function_pkey PRIMARY KEY (function_schema, function_name);
1715
1716
1717--
1718-- Name: hdb_permission hdb_permission_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1719--
1720
1721ALTER TABLE ONLY hdb_catalog.hdb_permission
1722 ADD CONSTRAINT hdb_permission_pkey PRIMARY KEY (table_schema, table_name, role_name, perm_type);
1723
1724
1725--
1726-- Name: hdb_query_collection hdb_query_collection_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1727--
1728
1729ALTER TABLE ONLY hdb_catalog.hdb_query_collection
1730 ADD CONSTRAINT hdb_query_collection_pkey PRIMARY KEY (collection_name);
1731
1732
1733--
1734-- Name: hdb_relationship hdb_relationship_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1735--
1736
1737ALTER TABLE ONLY hdb_catalog.hdb_relationship
1738 ADD CONSTRAINT hdb_relationship_pkey PRIMARY KEY (table_schema, table_name, rel_name);
1739
1740
1741--
1742-- Name: hdb_table hdb_table_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1743--
1744
1745ALTER TABLE ONLY hdb_catalog.hdb_table
1746 ADD CONSTRAINT hdb_table_pkey PRIMARY KEY (table_schema, table_name);
1747
1748
1749--
1750-- Name: hdb_version hdb_version_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1751--
1752
1753ALTER TABLE ONLY hdb_catalog.hdb_version
1754 ADD CONSTRAINT hdb_version_pkey PRIMARY KEY (hasura_uuid);
1755
1756
1757--
1758-- Name: migration_settings migration_settings_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1759--
1760
1761ALTER TABLE ONLY hdb_catalog.migration_settings
1762 ADD CONSTRAINT migration_settings_pkey PRIMARY KEY (setting);
1763
1764
1765--
1766-- Name: remote_schemas remote_schemas_name_key; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1767--
1768
1769ALTER TABLE ONLY hdb_catalog.remote_schemas
1770 ADD CONSTRAINT remote_schemas_name_key UNIQUE (name);
1771
1772
1773--
1774-- Name: remote_schemas remote_schemas_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1775--
1776
1777ALTER TABLE ONLY hdb_catalog.remote_schemas
1778 ADD CONSTRAINT remote_schemas_pkey PRIMARY KEY (id);
1779
1780
1781--
1782-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: hdb_catalog; Owner: postgres
1783--
1784
1785ALTER TABLE ONLY hdb_catalog.schema_migrations
1786 ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
1787
1788
1789--
1790-- Name: Auto Auto_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
1791--
1792
1793ALTER TABLE ONLY public."Auto"
1794 ADD CONSTRAINT "Auto_id_key" UNIQUE (id);
1795
1796
1797--
1798-- Name: Auto Auto_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1799--
1800
1801ALTER TABLE ONLY public."Auto"
1802 ADD CONSTRAINT "Auto_pkey" PRIMARY KEY (id);
1803
1804
1805--
1806-- Name: City City_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1807--
1808
1809ALTER TABLE ONLY public."City"
1810 ADD CONSTRAINT "City_pkey" PRIMARY KEY (id);
1811
1812
1813--
1814-- Name: Document Document_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1815--
1816
1817ALTER TABLE ONLY public."Document"
1818 ADD CONSTRAINT "Document_pkey" PRIMARY KEY (id);
1819
1820
1821--
1822-- Name: Driver Driver_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1823--
1824
1825ALTER TABLE ONLY public."Driver"
1826 ADD CONSTRAINT "Driver_pkey" PRIMARY KEY (id);
1827
1828
1829--
1830-- Name: EntityContractChanges EntityContractChanges_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1831--
1832
1833ALTER TABLE ONLY public."EntityContractChanges"
1834 ADD CONSTRAINT "EntityContractChanges_pkey" PRIMARY KEY (id);
1835
1836
1837--
1838-- Name: EntityContract EntityContract_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1839--
1840
1841ALTER TABLE ONLY public."EntityContract"
1842 ADD CONSTRAINT "EntityContract_pkey" PRIMARY KEY (id);
1843
1844
1845--
1846-- Name: Entity Entity_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1847--
1848
1849ALTER TABLE ONLY public."Entity"
1850 ADD CONSTRAINT "Entity_pkey" PRIMARY KEY (id);
1851
1852
1853--
1854-- Name: Expense Expense_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1855--
1856
1857ALTER TABLE ONLY public."Expense"
1858 ADD CONSTRAINT "Expense_pkey" PRIMARY KEY (id);
1859
1860
1861--
1862-- Name: File File_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1863--
1864
1865ALTER TABLE ONLY public."File"
1866 ADD CONSTRAINT "File_pkey" PRIMARY KEY (id);
1867
1868
1869--
1870-- Name: Inspection Inspection_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
1871--
1872
1873ALTER TABLE ONLY public."Inspection"
1874 ADD CONSTRAINT "Inspection_id_key" UNIQUE (id);
1875
1876
1877--
1878-- Name: Inspection Inspection_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1879--
1880
1881ALTER TABLE ONLY public."Inspection"
1882 ADD CONSTRAINT "Inspection_pkey" PRIMARY KEY (id);
1883
1884
1885--
1886-- Name: Intermediary Intermediary_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1887--
1888
1889ALTER TABLE ONLY public."Intermediary"
1890 ADD CONSTRAINT "Intermediary_pkey" PRIMARY KEY (id);
1891
1892
1893--
1894-- Name: Log Log_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1895--
1896
1897ALTER TABLE ONLY public."Log"
1898 ADD CONSTRAINT "Log_pkey" PRIMARY KEY (id);
1899
1900
1901--
1902-- Name: Office Office_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1903--
1904
1905ALTER TABLE ONLY public."Office"
1906 ADD CONSTRAINT "Office_pkey" PRIMARY KEY (id);
1907
1908
1909--
1910-- Name: Organization Organization_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1911--
1912
1913ALTER TABLE ONLY public."Organization"
1914 ADD CONSTRAINT "Organization_pkey" PRIMARY KEY (id);
1915
1916
1917--
1918-- Name: PaidMonth PaidMonth_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1919--
1920
1921ALTER TABLE ONLY public."PaidMonth"
1922 ADD CONSTRAINT "PaidMonth_pkey" PRIMARY KEY (id);
1923
1924
1925--
1926-- Name: OnlinePayment Payment_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1927--
1928
1929ALTER TABLE ONLY public."OnlinePayment"
1930 ADD CONSTRAINT "Payment_pkey" PRIMARY KEY (id);
1931
1932
1933--
1934-- Name: Payment Payment_pkey1; Type: CONSTRAINT; Schema: public; Owner: postgres
1935--
1936
1937ALTER TABLE ONLY public."Payment"
1938 ADD CONSTRAINT "Payment_pkey1" PRIMARY KEY (id);
1939
1940
1941--
1942-- Name: Role Role_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1943--
1944
1945ALTER TABLE ONLY public."Role"
1946 ADD CONSTRAINT "Role_pkey" PRIMARY KEY (id);
1947
1948
1949--
1950-- Name: Settings Settings_organizationId_key; Type: CONSTRAINT; Schema: public; Owner: postgres
1951--
1952
1953ALTER TABLE ONLY public."Settings"
1954 ADD CONSTRAINT "Settings_organizationId_key" UNIQUE ("organizationId");
1955
1956
1957--
1958-- Name: Settings Settings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1959--
1960
1961ALTER TABLE ONLY public."Settings"
1962 ADD CONSTRAINT "Settings_pkey" PRIMARY KEY ("organizationId");
1963
1964
1965--
1966-- Name: Tariff Tariff_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1967--
1968
1969ALTER TABLE ONLY public."Tariff"
1970 ADD CONSTRAINT "Tariff_pkey" PRIMARY KEY (id);
1971
1972
1973--
1974-- Name: User User_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1975--
1976
1977ALTER TABLE ONLY public."User"
1978 ADD CONSTRAINT "User_pkey" PRIMARY KEY (id);
1979
1980
1981--
1982-- Name: AutoGto autGto_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1983--
1984
1985ALTER TABLE ONLY public."AutoGto"
1986 ADD CONSTRAINT "autGto_pkey" PRIMARY KEY (id);
1987
1988
1989--
1990-- Name: AutoInsurance autoInsurance_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1991--
1992
1993ALTER TABLE ONLY public."AutoInsurance"
1994 ADD CONSTRAINT "autoInsurance_pkey" PRIMARY KEY (id);
1995
1996
1997--
1998-- Name: AutoSts autoSts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
1999--
2000
2001ALTER TABLE ONLY public."AutoSts"
2002 ADD CONSTRAINT "autoSts_pkey" PRIMARY KEY (id);
2003
2004
2005--
2006-- Name: DriverCertificate driverCertificates_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
2007--
2008
2009ALTER TABLE ONLY public."DriverCertificate"
2010 ADD CONSTRAINT "driverCertificates_pkey" PRIMARY KEY (id);
2011
2012
2013--
2014-- Name: event_invocation_logs_event_id_idx; Type: INDEX; Schema: hdb_catalog; Owner: postgres
2015--
2016
2017CREATE INDEX event_invocation_logs_event_id_idx ON hdb_catalog.event_invocation_logs USING btree (event_id);
2018
2019
2020--
2021-- Name: event_log_created_at_idx; Type: INDEX; Schema: hdb_catalog; Owner: postgres
2022--
2023
2024CREATE INDEX event_log_created_at_idx ON hdb_catalog.event_log USING btree (created_at);
2025
2026
2027--
2028-- Name: event_log_delivered_idx; Type: INDEX; Schema: hdb_catalog; Owner: postgres
2029--
2030
2031CREATE INDEX event_log_delivered_idx ON hdb_catalog.event_log USING btree (delivered);
2032
2033
2034--
2035-- Name: event_log_locked_idx; Type: INDEX; Schema: hdb_catalog; Owner: postgres
2036--
2037
2038CREATE INDEX event_log_locked_idx ON hdb_catalog.event_log USING btree (locked);
2039
2040
2041--
2042-- Name: event_log_trigger_name_idx; Type: INDEX; Schema: hdb_catalog; Owner: postgres
2043--
2044
2045CREATE INDEX event_log_trigger_name_idx ON hdb_catalog.event_log USING btree (trigger_name);
2046
2047
2048--
2049-- Name: hdb_schema_update_event_one_row; Type: INDEX; Schema: hdb_catalog; Owner: postgres
2050--
2051
2052CREATE UNIQUE INDEX hdb_schema_update_event_one_row ON hdb_catalog.hdb_schema_update_event USING btree (((occurred_at IS NOT NULL)));
2053
2054
2055--
2056-- Name: hdb_version_one_row; Type: INDEX; Schema: hdb_catalog; Owner: postgres
2057--
2058
2059CREATE UNIQUE INDEX hdb_version_one_row ON hdb_catalog.hdb_version USING btree (((version IS NOT NULL)));
2060
2061
2062--
2063-- Name: driver_search_idx; Type: INDEX; Schema: public; Owner: postgres
2064--
2065
2066CREATE INDEX driver_search_idx ON public."Driver" USING gin (((((("secondName" || ' '::text) || "firstName") || ' '::text) || "middleName")) public.gin_trgm_ops);
2067
2068
2069--
2070-- Name: hdb_schema_update_event hdb_schema_update_event_notifier; Type: TRIGGER; Schema: hdb_catalog; Owner: postgres
2071--
2072
2073CREATE TRIGGER hdb_schema_update_event_notifier AFTER INSERT OR UPDATE ON hdb_catalog.hdb_schema_update_event FOR EACH ROW EXECUTE FUNCTION hdb_catalog.hdb_schema_update_event_notifier();
2074
2075
2076--
2077-- Name: Entity notify_hasura_onEntityCreated_INSERT; Type: TRIGGER; Schema: public; Owner: postgres
2078--
2079
2080CREATE TRIGGER "notify_hasura_onEntityCreated_INSERT" AFTER INSERT ON public."Entity" FOR EACH ROW EXECUTE FUNCTION hdb_views."notify_hasura_onEntityCreated_INSERT"();
2081
2082
2083--
2084-- Name: AutoGto set_public_AutoGto_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2085--
2086
2087CREATE TRIGGER "set_public_AutoGto_updated_at" BEFORE UPDATE ON public."AutoGto" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2088
2089
2090--
2091-- Name: TRIGGER "set_public_AutoGto_updated_at" ON "AutoGto"; Type: COMMENT; Schema: public; Owner: postgres
2092--
2093
2094COMMENT ON TRIGGER "set_public_AutoGto_updated_at" ON public."AutoGto" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2095
2096
2097--
2098-- Name: AutoInsurance set_public_AutoInsurance_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2099--
2100
2101CREATE TRIGGER "set_public_AutoInsurance_updated_at" BEFORE UPDATE ON public."AutoInsurance" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2102
2103
2104--
2105-- Name: TRIGGER "set_public_AutoInsurance_updated_at" ON "AutoInsurance"; Type: COMMENT; Schema: public; Owner: postgres
2106--
2107
2108COMMENT ON TRIGGER "set_public_AutoInsurance_updated_at" ON public."AutoInsurance" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2109
2110
2111--
2112-- Name: AutoSts set_public_AutoSts_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2113--
2114
2115CREATE TRIGGER "set_public_AutoSts_updated_at" BEFORE UPDATE ON public."AutoSts" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2116
2117
2118--
2119-- Name: TRIGGER "set_public_AutoSts_updated_at" ON "AutoSts"; Type: COMMENT; Schema: public; Owner: postgres
2120--
2121
2122COMMENT ON TRIGGER "set_public_AutoSts_updated_at" ON public."AutoSts" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2123
2124
2125--
2126-- Name: Auto set_public_Auto_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2127--
2128
2129CREATE TRIGGER "set_public_Auto_updated_at" BEFORE UPDATE ON public."Auto" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2130
2131
2132--
2133-- Name: TRIGGER "set_public_Auto_updated_at" ON "Auto"; Type: COMMENT; Schema: public; Owner: postgres
2134--
2135
2136COMMENT ON TRIGGER "set_public_Auto_updated_at" ON public."Auto" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2137
2138
2139--
2140-- Name: Document set_public_Document_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2141--
2142
2143CREATE TRIGGER "set_public_Document_updated_at" BEFORE UPDATE ON public."Document" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2144
2145
2146--
2147-- Name: TRIGGER "set_public_Document_updated_at" ON "Document"; Type: COMMENT; Schema: public; Owner: postgres
2148--
2149
2150COMMENT ON TRIGGER "set_public_Document_updated_at" ON public."Document" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2151
2152
2153--
2154-- Name: DriverCertificate set_public_DriverCertificate_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2155--
2156
2157CREATE TRIGGER "set_public_DriverCertificate_updated_at" BEFORE UPDATE ON public."DriverCertificate" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2158
2159
2160--
2161-- Name: TRIGGER "set_public_DriverCertificate_updated_at" ON "DriverCertificate"; Type: COMMENT; Schema: public; Owner: postgres
2162--
2163
2164COMMENT ON TRIGGER "set_public_DriverCertificate_updated_at" ON public."DriverCertificate" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2165
2166
2167--
2168-- Name: Driver set_public_Driver_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2169--
2170
2171CREATE TRIGGER "set_public_Driver_updated_at" BEFORE UPDATE ON public."Driver" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2172
2173
2174--
2175-- Name: TRIGGER "set_public_Driver_updated_at" ON "Driver"; Type: COMMENT; Schema: public; Owner: postgres
2176--
2177
2178COMMENT ON TRIGGER "set_public_Driver_updated_at" ON public."Driver" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2179
2180
2181--
2182-- Name: EntityContractChanges set_public_EntityContractChanges_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2183--
2184
2185CREATE TRIGGER "set_public_EntityContractChanges_updated_at" BEFORE UPDATE ON public."EntityContractChanges" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2186
2187
2188--
2189-- Name: TRIGGER "set_public_EntityContractChanges_updated_at" ON "EntityContractChanges"; Type: COMMENT; Schema: public; Owner: postgres
2190--
2191
2192COMMENT ON TRIGGER "set_public_EntityContractChanges_updated_at" ON public."EntityContractChanges" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2193
2194
2195--
2196-- Name: EntityContract set_public_EntityContract_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2197--
2198
2199CREATE TRIGGER "set_public_EntityContract_updated_at" BEFORE UPDATE ON public."EntityContract" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2200
2201
2202--
2203-- Name: TRIGGER "set_public_EntityContract_updated_at" ON "EntityContract"; Type: COMMENT; Schema: public; Owner: postgres
2204--
2205
2206COMMENT ON TRIGGER "set_public_EntityContract_updated_at" ON public."EntityContract" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2207
2208
2209--
2210-- Name: Entity set_public_Entity_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2211--
2212
2213CREATE TRIGGER "set_public_Entity_updated_at" BEFORE UPDATE ON public."Entity" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2214
2215
2216--
2217-- Name: TRIGGER "set_public_Entity_updated_at" ON "Entity"; Type: COMMENT; Schema: public; Owner: postgres
2218--
2219
2220COMMENT ON TRIGGER "set_public_Entity_updated_at" ON public."Entity" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2221
2222
2223--
2224-- Name: Expense set_public_Expense_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2225--
2226
2227CREATE TRIGGER "set_public_Expense_updated_at" BEFORE UPDATE ON public."Expense" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2228
2229
2230--
2231-- Name: TRIGGER "set_public_Expense_updated_at" ON "Expense"; Type: COMMENT; Schema: public; Owner: postgres
2232--
2233
2234COMMENT ON TRIGGER "set_public_Expense_updated_at" ON public."Expense" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2235
2236
2237--
2238-- Name: Inspection set_public_Inspection_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2239--
2240
2241CREATE TRIGGER "set_public_Inspection_updated_at" BEFORE UPDATE ON public."Inspection" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2242
2243
2244--
2245-- Name: TRIGGER "set_public_Inspection_updated_at" ON "Inspection"; Type: COMMENT; Schema: public; Owner: postgres
2246--
2247
2248COMMENT ON TRIGGER "set_public_Inspection_updated_at" ON public."Inspection" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2249
2250
2251--
2252-- Name: Intermediary set_public_Intermediary_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2253--
2254
2255CREATE TRIGGER "set_public_Intermediary_updated_at" BEFORE UPDATE ON public."Intermediary" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2256
2257
2258--
2259-- Name: TRIGGER "set_public_Intermediary_updated_at" ON "Intermediary"; Type: COMMENT; Schema: public; Owner: postgres
2260--
2261
2262COMMENT ON TRIGGER "set_public_Intermediary_updated_at" ON public."Intermediary" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2263
2264
2265--
2266-- Name: Organization set_public_Organization_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2267--
2268
2269CREATE TRIGGER "set_public_Organization_updated_at" BEFORE UPDATE ON public."Organization" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2270
2271
2272--
2273-- Name: TRIGGER "set_public_Organization_updated_at" ON "Organization"; Type: COMMENT; Schema: public; Owner: postgres
2274--
2275
2276COMMENT ON TRIGGER "set_public_Organization_updated_at" ON public."Organization" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2277
2278
2279--
2280-- Name: OnlinePayment set_public_Payment_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2281--
2282
2283CREATE TRIGGER "set_public_Payment_updated_at" BEFORE UPDATE ON public."OnlinePayment" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2284
2285
2286--
2287-- Name: TRIGGER "set_public_Payment_updated_at" ON "OnlinePayment"; Type: COMMENT; Schema: public; Owner: postgres
2288--
2289
2290COMMENT ON TRIGGER "set_public_Payment_updated_at" ON public."OnlinePayment" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2291
2292
2293--
2294-- Name: Payment set_public_Payment_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2295--
2296
2297CREATE TRIGGER "set_public_Payment_updated_at" BEFORE UPDATE ON public."Payment" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2298
2299
2300--
2301-- Name: TRIGGER "set_public_Payment_updated_at" ON "Payment"; Type: COMMENT; Schema: public; Owner: postgres
2302--
2303
2304COMMENT ON TRIGGER "set_public_Payment_updated_at" ON public."Payment" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2305
2306
2307--
2308-- Name: Role set_public_Role_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2309--
2310
2311CREATE TRIGGER "set_public_Role_updated_at" BEFORE UPDATE ON public."Role" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2312
2313
2314--
2315-- Name: TRIGGER "set_public_Role_updated_at" ON "Role"; Type: COMMENT; Schema: public; Owner: postgres
2316--
2317
2318COMMENT ON TRIGGER "set_public_Role_updated_at" ON public."Role" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2319
2320
2321--
2322-- Name: User set_public_User_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2323--
2324
2325CREATE TRIGGER "set_public_User_updated_at" BEFORE UPDATE ON public."User" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2326
2327
2328--
2329-- Name: TRIGGER "set_public_User_updated_at" ON "User"; Type: COMMENT; Schema: public; Owner: postgres
2330--
2331
2332COMMENT ON TRIGGER "set_public_User_updated_at" ON public."User" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2333
2334
2335--
2336-- Name: Office set_public_offices_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
2337--
2338
2339CREATE TRIGGER set_public_offices_updated_at BEFORE UPDATE ON public."Office" FOR EACH ROW EXECUTE FUNCTION public.set_current_timestamp_updated_at();
2340
2341
2342--
2343-- Name: TRIGGER set_public_offices_updated_at ON "Office"; Type: COMMENT; Schema: public; Owner: postgres
2344--
2345
2346COMMENT ON TRIGGER set_public_offices_updated_at ON public."Office" IS 'trigger to set value of column "updated_at" to current timestamp on row update';
2347
2348
2349--
2350-- Name: event_invocation_logs event_invocation_logs_event_id_fkey; Type: FK CONSTRAINT; Schema: hdb_catalog; Owner: postgres
2351--
2352
2353ALTER TABLE ONLY hdb_catalog.event_invocation_logs
2354 ADD CONSTRAINT event_invocation_logs_event_id_fkey FOREIGN KEY (event_id) REFERENCES hdb_catalog.event_log(id);
2355
2356
2357--
2358-- Name: event_triggers event_triggers_schema_name_table_name_fkey; Type: FK CONSTRAINT; Schema: hdb_catalog; Owner: postgres
2359--
2360
2361ALTER TABLE ONLY hdb_catalog.event_triggers
2362 ADD CONSTRAINT event_triggers_schema_name_table_name_fkey FOREIGN KEY (schema_name, table_name) REFERENCES hdb_catalog.hdb_table(table_schema, table_name) ON UPDATE CASCADE;
2363
2364
2365--
2366-- Name: hdb_action_permission hdb_action_permission_action_name_fkey; Type: FK CONSTRAINT; Schema: hdb_catalog; Owner: postgres
2367--
2368
2369ALTER TABLE ONLY hdb_catalog.hdb_action_permission
2370 ADD CONSTRAINT hdb_action_permission_action_name_fkey FOREIGN KEY (action_name) REFERENCES hdb_catalog.hdb_action(action_name) ON UPDATE CASCADE;
2371
2372
2373--
2374-- Name: hdb_allowlist hdb_allowlist_collection_name_fkey; Type: FK CONSTRAINT; Schema: hdb_catalog; Owner: postgres
2375--
2376
2377ALTER TABLE ONLY hdb_catalog.hdb_allowlist
2378 ADD CONSTRAINT hdb_allowlist_collection_name_fkey FOREIGN KEY (collection_name) REFERENCES hdb_catalog.hdb_query_collection(collection_name);
2379
2380
2381--
2382-- Name: hdb_computed_field hdb_computed_field_table_schema_table_name_fkey; Type: FK CONSTRAINT; Schema: hdb_catalog; Owner: postgres
2383--
2384
2385ALTER TABLE ONLY hdb_catalog.hdb_computed_field
2386 ADD CONSTRAINT hdb_computed_field_table_schema_table_name_fkey FOREIGN KEY (table_schema, table_name) REFERENCES hdb_catalog.hdb_table(table_schema, table_name) ON UPDATE CASCADE;
2387
2388
2389--
2390-- Name: hdb_permission hdb_permission_table_schema_table_name_fkey; Type: FK CONSTRAINT; Schema: hdb_catalog; Owner: postgres
2391--
2392
2393ALTER TABLE ONLY hdb_catalog.hdb_permission
2394 ADD CONSTRAINT hdb_permission_table_schema_table_name_fkey FOREIGN KEY (table_schema, table_name) REFERENCES hdb_catalog.hdb_table(table_schema, table_name) ON UPDATE CASCADE;
2395
2396
2397--
2398-- Name: hdb_relationship hdb_relationship_table_schema_table_name_fkey; Type: FK CONSTRAINT; Schema: hdb_catalog; Owner: postgres
2399--
2400
2401ALTER TABLE ONLY hdb_catalog.hdb_relationship
2402 ADD CONSTRAINT hdb_relationship_table_schema_table_name_fkey FOREIGN KEY (table_schema, table_name) REFERENCES hdb_catalog.hdb_table(table_schema, table_name) ON UPDATE CASCADE;
2403
2404
2405--
2406-- Name: Auto Auto_contractId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2407--
2408
2409ALTER TABLE ONLY public."Auto"
2410 ADD CONSTRAINT "Auto_contractId_fkey" FOREIGN KEY ("contractId") REFERENCES public."EntityContract"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2411
2412
2413--
2414-- Name: Auto Auto_driverId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2415--
2416
2417ALTER TABLE ONLY public."Auto"
2418 ADD CONSTRAINT "Auto_driverId_fkey" FOREIGN KEY ("driverId") REFERENCES public."Driver"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2419
2420
2421--
2422-- Name: Document Document_cityId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2423--
2424
2425ALTER TABLE ONLY public."Document"
2426 ADD CONSTRAINT "Document_cityId_fkey" FOREIGN KEY ("cityId") REFERENCES public."City"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2427
2428
2429--
2430-- Name: Document Document_fileId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2431--
2432
2433ALTER TABLE ONLY public."Document"
2434 ADD CONSTRAINT "Document_fileId_fkey" FOREIGN KEY ("fileId") REFERENCES public."File"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2435
2436
2437--
2438-- Name: Document Document_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2439--
2440
2441ALTER TABLE ONLY public."Document"
2442 ADD CONSTRAINT "Document_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2443
2444
2445--
2446-- Name: Driver Driver_contractId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2447--
2448
2449ALTER TABLE ONLY public."Driver"
2450 ADD CONSTRAINT "Driver_contractId_fkey" FOREIGN KEY ("contractId") REFERENCES public."EntityContract"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2451
2452
2453--
2454-- Name: Driver Driver_intermediaryId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2455--
2456
2457ALTER TABLE ONLY public."Driver"
2458 ADD CONSTRAINT "Driver_intermediaryId_fkey" FOREIGN KEY ("intermediaryId") REFERENCES public."Intermediary"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2459
2460
2461--
2462-- Name: Driver Driver_officeId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2463--
2464
2465ALTER TABLE ONLY public."Driver"
2466 ADD CONSTRAINT "Driver_officeId_fkey" FOREIGN KEY ("officeId") REFERENCES public."Office"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2467
2468
2469--
2470-- Name: Driver Driver_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2471--
2472
2473ALTER TABLE ONLY public."Driver"
2474 ADD CONSTRAINT "Driver_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2475
2476
2477--
2478-- Name: EntityContractChanges EntityContractChanges_contractId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2479--
2480
2481ALTER TABLE ONLY public."EntityContractChanges"
2482 ADD CONSTRAINT "EntityContractChanges_contractId_fkey" FOREIGN KEY ("contractId") REFERENCES public."EntityContract"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2483
2484
2485--
2486-- Name: EntityContract EntityContract_entityId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2487--
2488
2489ALTER TABLE ONLY public."EntityContract"
2490 ADD CONSTRAINT "EntityContract_entityId_fkey" FOREIGN KEY ("entityId") REFERENCES public."Entity"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2491
2492
2493--
2494-- Name: Entity Entity_intermediaryId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2495--
2496
2497ALTER TABLE ONLY public."Entity"
2498 ADD CONSTRAINT "Entity_intermediaryId_fkey" FOREIGN KEY ("intermediaryId") REFERENCES public."Intermediary"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2499
2500
2501--
2502-- Name: Entity Entity_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2503--
2504
2505ALTER TABLE ONLY public."Entity"
2506 ADD CONSTRAINT "Entity_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2507
2508
2509--
2510-- Name: Expense Expense_creatorId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2511--
2512
2513ALTER TABLE ONLY public."Expense"
2514 ADD CONSTRAINT "Expense_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES public."User"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2515
2516
2517--
2518-- Name: Expense Expense_officeId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2519--
2520
2521ALTER TABLE ONLY public."Expense"
2522 ADD CONSTRAINT "Expense_officeId_fkey" FOREIGN KEY ("officeId") REFERENCES public."Office"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2523
2524
2525--
2526-- Name: Expense Expense_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2527--
2528
2529ALTER TABLE ONLY public."Expense"
2530 ADD CONSTRAINT "Expense_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2531
2532
2533--
2534-- Name: File File_contractId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2535--
2536
2537ALTER TABLE ONLY public."File"
2538 ADD CONSTRAINT "File_contractId_fkey" FOREIGN KEY ("contractId") REFERENCES public."EntityContract"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2539
2540
2541--
2542-- Name: File File_driverId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2543--
2544
2545ALTER TABLE ONLY public."File"
2546 ADD CONSTRAINT "File_driverId_fkey" FOREIGN KEY ("driverId") REFERENCES public."Driver"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2547
2548
2549--
2550-- Name: File File_inspectionId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2551--
2552
2553ALTER TABLE ONLY public."File"
2554 ADD CONSTRAINT "File_inspectionId_fkey" FOREIGN KEY ("inspectionId") REFERENCES public."Inspection"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2555
2556
2557--
2558-- Name: Inspection Inspection_autoId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2559--
2560
2561ALTER TABLE ONLY public."Inspection"
2562 ADD CONSTRAINT "Inspection_autoId_fkey" FOREIGN KEY ("autoId") REFERENCES public."Auto"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2563
2564
2565--
2566-- Name: Inspection Inspection_creatorId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2567--
2568
2569ALTER TABLE ONLY public."Inspection"
2570 ADD CONSTRAINT "Inspection_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES public."User"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2571
2572
2573--
2574-- Name: Inspection Inspection_driverId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2575--
2576
2577ALTER TABLE ONLY public."Inspection"
2578 ADD CONSTRAINT "Inspection_driverId_fkey" FOREIGN KEY ("driverId") REFERENCES public."Driver"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2579
2580
2581--
2582-- Name: Inspection Inspection_medicId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2583--
2584
2585ALTER TABLE ONLY public."Inspection"
2586 ADD CONSTRAINT "Inspection_medicId_fkey" FOREIGN KEY ("medicId") REFERENCES public."User"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2587
2588
2589--
2590-- Name: Inspection Inspection_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2591--
2592
2593ALTER TABLE ONLY public."Inspection"
2594 ADD CONSTRAINT "Inspection_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2595
2596
2597--
2598-- Name: Inspection Inspection_technicianId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2599--
2600
2601ALTER TABLE ONLY public."Inspection"
2602 ADD CONSTRAINT "Inspection_technicianId_fkey" FOREIGN KEY ("technicianId") REFERENCES public."User"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2603
2604
2605--
2606-- Name: Intermediary Intermediary_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2607--
2608
2609ALTER TABLE ONLY public."Intermediary"
2610 ADD CONSTRAINT "Intermediary_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2611
2612
2613--
2614-- Name: Log Log_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2615--
2616
2617ALTER TABLE ONLY public."Log"
2618 ADD CONSTRAINT "Log_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2619
2620
2621--
2622-- Name: Office Office_cityId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2623--
2624
2625ALTER TABLE ONLY public."Office"
2626 ADD CONSTRAINT "Office_cityId_fkey" FOREIGN KEY ("cityId") REFERENCES public."City"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2627
2628
2629--
2630-- Name: Office Office_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2631--
2632
2633ALTER TABLE ONLY public."Office"
2634 ADD CONSTRAINT "Office_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2635
2636
2637--
2638-- Name: PaidMonth PaidMonth_contractId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2639--
2640
2641ALTER TABLE ONLY public."PaidMonth"
2642 ADD CONSTRAINT "PaidMonth_contractId_fkey" FOREIGN KEY ("contractId") REFERENCES public."EntityContract"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2643
2644
2645--
2646-- Name: PaidMonth PaidMonth_paymentId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2647--
2648
2649ALTER TABLE ONLY public."PaidMonth"
2650 ADD CONSTRAINT "PaidMonth_paymentId_fkey" FOREIGN KEY ("paymentId") REFERENCES public."Payment"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2651
2652
2653--
2654-- Name: Payment Payment_contractId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2655--
2656
2657ALTER TABLE ONLY public."Payment"
2658 ADD CONSTRAINT "Payment_contractId_fkey" FOREIGN KEY ("contractId") REFERENCES public."EntityContract"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2659
2660
2661--
2662-- Name: OnlinePayment Payment_creatorId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2663--
2664
2665ALTER TABLE ONLY public."OnlinePayment"
2666 ADD CONSTRAINT "Payment_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES public."User"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2667
2668
2669--
2670-- Name: Payment Payment_creatorId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2671--
2672
2673ALTER TABLE ONLY public."Payment"
2674 ADD CONSTRAINT "Payment_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES public."User"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2675
2676
2677--
2678-- Name: OnlinePayment Payment_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2679--
2680
2681ALTER TABLE ONLY public."OnlinePayment"
2682 ADD CONSTRAINT "Payment_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2683
2684
2685--
2686-- Name: Payment Payment_organizationId_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2687--
2688
2689ALTER TABLE ONLY public."Payment"
2690 ADD CONSTRAINT "Payment_organizationId_fkey1" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2691
2692
2693--
2694-- Name: Payment Payment_tariffId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2695--
2696
2697ALTER TABLE ONLY public."Payment"
2698 ADD CONSTRAINT "Payment_tariffId_fkey" FOREIGN KEY ("tariffId") REFERENCES public."Tariff"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2699
2700
2701--
2702-- Name: Role Role_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2703--
2704
2705ALTER TABLE ONLY public."Role"
2706 ADD CONSTRAINT "Role_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2707
2708
2709--
2710-- Name: Settings Settings_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2711--
2712
2713ALTER TABLE ONLY public."Settings"
2714 ADD CONSTRAINT "Settings_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2715
2716
2717--
2718-- Name: Tariff Tariff_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2719--
2720
2721ALTER TABLE ONLY public."Tariff"
2722 ADD CONSTRAINT "Tariff_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2723
2724
2725--
2726-- Name: User User_entityId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2727--
2728
2729ALTER TABLE ONLY public."User"
2730 ADD CONSTRAINT "User_entityId_fkey" FOREIGN KEY ("entityId") REFERENCES public."Entity"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2731
2732
2733--
2734-- Name: User User_officeId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2735--
2736
2737ALTER TABLE ONLY public."User"
2738 ADD CONSTRAINT "User_officeId_fkey" FOREIGN KEY ("officeId") REFERENCES public."Office"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2739
2740
2741--
2742-- Name: User User_organizationId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
2743--
2744
2745ALTER TABLE ONLY public."User"
2746 ADD CONSTRAINT "User_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES public."Organization"(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
2747
2748
2749--
2750-- PostgreSQL database dump complete
2751--