forked from 3scale/zync
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructure.sql
More file actions
1535 lines (1056 loc) · 37.4 KB
/
structure.sql
File metadata and controls
1535 lines (1056 loc) · 37.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: integration_state; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.integration_state AS ENUM (
'active',
'disabled'
);
--
-- Name: que_validate_tags(jsonb); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.que_validate_tags(tags_array jsonb) RETURNS boolean
LANGUAGE sql
AS $$
SELECT bool_and(
jsonb_typeof(value) = 'string'
AND
char_length(value::text) <= 100
)
FROM jsonb_array_elements(tags_array)
$$;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: que_jobs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.que_jobs (
priority smallint DEFAULT 100 NOT NULL,
run_at timestamp with time zone DEFAULT now() NOT NULL,
id bigint NOT NULL,
job_class text NOT NULL,
error_count integer DEFAULT 0 NOT NULL,
last_error_message text,
queue text DEFAULT 'default'::text NOT NULL,
last_error_backtrace text,
finished_at timestamp with time zone,
expired_at timestamp with time zone,
args jsonb DEFAULT '[]'::jsonb NOT NULL,
data jsonb DEFAULT '{}'::jsonb NOT NULL,
job_schema_version integer NOT NULL,
kwargs jsonb DEFAULT '{}'::jsonb NOT NULL,
CONSTRAINT error_length CHECK (((char_length(last_error_message) <= 500) AND (char_length(last_error_backtrace) <= 10000))),
CONSTRAINT job_class_length CHECK ((char_length(
CASE job_class
WHEN 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper'::text THEN ((args -> 0) ->> 'job_class'::text)
ELSE job_class
END) <= 200)),
CONSTRAINT queue_length CHECK ((char_length(queue) <= 100)),
CONSTRAINT valid_args CHECK ((jsonb_typeof(args) = 'array'::text)),
CONSTRAINT valid_data CHECK (((jsonb_typeof(data) = 'object'::text) AND ((NOT (data ? 'tags'::text)) OR ((jsonb_typeof((data -> 'tags'::text)) = 'array'::text) AND (jsonb_array_length((data -> 'tags'::text)) <= 5) AND public.que_validate_tags((data -> 'tags'::text))))))
)
WITH (fillfactor='90');
--
-- Name: TABLE que_jobs; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON TABLE public.que_jobs IS '7';
--
-- Name: que_determine_job_state(public.que_jobs); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.que_determine_job_state(job public.que_jobs) RETURNS text
LANGUAGE sql
AS $$
SELECT
CASE
WHEN job.expired_at IS NOT NULL THEN 'expired'
WHEN job.finished_at IS NOT NULL THEN 'finished'
WHEN job.error_count > 0 THEN 'errored'
WHEN job.run_at > CURRENT_TIMESTAMP THEN 'scheduled'
ELSE 'ready'
END
$$;
--
-- Name: que_job_notify(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.que_job_notify() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
locker_pid integer;
sort_key json;
BEGIN
-- Don't do anything if the job is scheduled for a future time.
IF NEW.run_at IS NOT NULL AND NEW.run_at > now() THEN
RETURN null;
END IF;
-- Pick a locker to notify of the job's insertion, weighted by their number
-- of workers. Should bounce pseudorandomly between lockers on each
-- invocation, hence the hashtext-ordering, but still touch each one equally,
-- hence the modulo using the job_id.
SELECT pid
INTO locker_pid
FROM (
SELECT *, last_value(row_number) OVER () + 1 AS count
FROM (
SELECT *, row_number() OVER () - 1 AS row_number
FROM (
SELECT *
FROM public.que_lockers ql, generate_series(1, ql.worker_count) AS id
WHERE
listening AND
queues @> ARRAY[NEW.queue] AND
ql.job_schema_version = NEW.job_schema_version
ORDER BY hashtext(pid::text || id::text)
) t1
) t2
) t3
WHERE NEW.id % count = row_number;
IF locker_pid IS NOT NULL THEN
-- There's a size limit to what can be broadcast via LISTEN/NOTIFY, so
-- rather than throw errors when someone enqueues a big job, just
-- broadcast the most pertinent information, and let the locker query for
-- the record after it's taken the lock. The worker will have to hit the
-- DB in order to make sure the job is still visible anyway.
SELECT row_to_json(t)
INTO sort_key
FROM (
SELECT
'job_available' AS message_type,
NEW.queue AS queue,
NEW.priority AS priority,
NEW.id AS id,
-- Make sure we output timestamps as UTC ISO 8601
to_char(NEW.run_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"') AS run_at
) t;
PERFORM pg_notify('que_listener_' || locker_pid::text, sort_key::text);
END IF;
RETURN null;
END
$$;
--
-- Name: que_state_notify(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.que_state_notify() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
row record;
message json;
previous_state text;
current_state text;
BEGIN
IF TG_OP = 'INSERT' THEN
previous_state := 'nonexistent';
current_state := public.que_determine_job_state(NEW);
row := NEW;
ELSIF TG_OP = 'DELETE' THEN
previous_state := public.que_determine_job_state(OLD);
current_state := 'nonexistent';
row := OLD;
ELSIF TG_OP = 'UPDATE' THEN
previous_state := public.que_determine_job_state(OLD);
current_state := public.que_determine_job_state(NEW);
-- If the state didn't change, short-circuit.
IF previous_state = current_state THEN
RETURN null;
END IF;
row := NEW;
ELSE
RAISE EXCEPTION 'Unrecognized TG_OP: %', TG_OP;
END IF;
SELECT row_to_json(t)
INTO message
FROM (
SELECT
'job_change' AS message_type,
row.id AS id,
row.queue AS queue,
coalesce(row.data->'tags', '[]'::jsonb) AS tags,
to_char(row.run_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"') AS run_at,
to_char(now() AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"') AS time,
CASE row.job_class
WHEN 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper' THEN
coalesce(
row.args->0->>'job_class',
'ActiveJob::QueueAdapters::QueAdapter::JobWrapper'
)
ELSE
row.job_class
END AS job_class,
previous_state AS previous_state,
current_state AS current_state
) t;
PERFORM pg_notify('que_state', message::text);
RETURN null;
END
$$;
--
-- Name: applications; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.applications (
id bigint NOT NULL,
tenant_id bigint NOT NULL,
service_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: applications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.applications_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: applications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.applications_id_seq OWNED BY public.applications.id;
--
-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.ar_internal_metadata (
key character varying NOT NULL,
value character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL
);
--
-- Name: clients; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.clients (
id bigint NOT NULL,
service_id bigint NOT NULL,
tenant_id bigint NOT NULL,
client_id character varying NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: clients_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.clients_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: clients_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.clients_id_seq OWNED BY public.clients.id;
--
-- Name: entries; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.entries (
id bigint NOT NULL,
data jsonb,
tenant_id bigint NOT NULL,
model_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: entries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.entries_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.entries_id_seq OWNED BY public.entries.id;
--
-- Name: integration_states; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.integration_states (
id bigint NOT NULL,
started_at timestamp without time zone,
finished_at timestamp without time zone,
success boolean,
model_id bigint NOT NULL,
entry_id bigint,
integration_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: integration_states_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.integration_states_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: integration_states_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.integration_states_id_seq OWNED BY public.integration_states.id;
--
-- Name: integrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.integrations (
id bigint NOT NULL,
configuration jsonb,
type character varying NOT NULL,
tenant_id bigint,
model_id bigint,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
state public.integration_state DEFAULT 'active'::public.integration_state NOT NULL
);
--
-- Name: integrations_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.integrations_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: integrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.integrations_id_seq OWNED BY public.integrations.id;
--
-- Name: message_bus; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.message_bus (
id bigint NOT NULL,
channel text NOT NULL,
value text NOT NULL,
added_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
CONSTRAINT message_bus_value_check CHECK ((octet_length(value) >= 2))
);
--
-- Name: message_bus_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.message_bus_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: message_bus_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.message_bus_id_seq OWNED BY public.message_bus.id;
--
-- Name: metrics; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.metrics (
id bigint NOT NULL,
service_id bigint NOT NULL,
tenant_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: metrics_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.metrics_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: metrics_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.metrics_id_seq OWNED BY public.metrics.id;
--
-- Name: models; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.models (
id bigint NOT NULL,
tenant_id bigint NOT NULL,
record_type character varying NOT NULL,
record_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: models_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.models_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: models_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.models_id_seq OWNED BY public.models.id;
--
-- Name: notifications; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.notifications (
id bigint NOT NULL,
model_id bigint NOT NULL,
data jsonb NOT NULL,
tenant_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: notifications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.notifications_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: notifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.notifications_id_seq OWNED BY public.notifications.id;
--
-- Name: providers; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.providers (
id bigint NOT NULL,
tenant_id bigint,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: providers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.providers_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: providers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.providers_id_seq OWNED BY public.providers.id;
--
-- Name: proxies; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.proxies (
id bigint NOT NULL,
tenant_id bigint NOT NULL,
service_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: proxies_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.proxies_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: proxies_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.proxies_id_seq OWNED BY public.proxies.id;
--
-- Name: que_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.que_jobs_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: que_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.que_jobs_id_seq OWNED BY public.que_jobs.id;
--
-- Name: que_lockers; Type: TABLE; Schema: public; Owner: -
--
CREATE UNLOGGED TABLE public.que_lockers (
pid integer NOT NULL,
worker_count integer NOT NULL,
worker_priorities integer[] NOT NULL,
ruby_pid integer NOT NULL,
ruby_hostname text NOT NULL,
queues text[] NOT NULL,
listening boolean NOT NULL,
job_schema_version integer DEFAULT 1,
CONSTRAINT valid_queues CHECK (((array_ndims(queues) = 1) AND (array_length(queues, 1) IS NOT NULL))),
CONSTRAINT valid_worker_priorities CHECK (((array_ndims(worker_priorities) = 1) AND (array_length(worker_priorities, 1) IS NOT NULL)))
);
--
-- Name: que_values; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.que_values (
key text NOT NULL,
value jsonb DEFAULT '{}'::jsonb NOT NULL,
CONSTRAINT valid_value CHECK ((jsonb_typeof(value) = 'object'::text))
)
WITH (fillfactor='90');
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.schema_migrations (
version character varying NOT NULL
);
--
-- Name: services; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.services (
id bigint NOT NULL,
tenant_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: services_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.services_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: services_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.services_id_seq OWNED BY public.services.id;
--
-- Name: tenants; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.tenants (
id bigint NOT NULL,
endpoint character varying NOT NULL,
access_token character varying NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: tenants_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.tenants_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: tenants_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.tenants_id_seq OWNED BY public.tenants.id;
--
-- Name: update_states; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.update_states (
id bigint NOT NULL,
started_at timestamp without time zone,
finished_at timestamp without time zone,
success boolean DEFAULT false NOT NULL,
model_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: update_states_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.update_states_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: update_states_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.update_states_id_seq OWNED BY public.update_states.id;
--
-- Name: usage_limits; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.usage_limits (
id bigint NOT NULL,
metric_id bigint NOT NULL,
plan_id integer NOT NULL,
tenant_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: usage_limits_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.usage_limits_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: usage_limits_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.usage_limits_id_seq OWNED BY public.usage_limits.id;
--
-- Name: applications id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.applications ALTER COLUMN id SET DEFAULT nextval('public.applications_id_seq'::regclass);
--
-- Name: clients id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.clients ALTER COLUMN id SET DEFAULT nextval('public.clients_id_seq'::regclass);
--
-- Name: entries id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.entries ALTER COLUMN id SET DEFAULT nextval('public.entries_id_seq'::regclass);
--
-- Name: integration_states id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.integration_states ALTER COLUMN id SET DEFAULT nextval('public.integration_states_id_seq'::regclass);
--
-- Name: integrations id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.integrations ALTER COLUMN id SET DEFAULT nextval('public.integrations_id_seq'::regclass);
--
-- Name: message_bus id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.message_bus ALTER COLUMN id SET DEFAULT nextval('public.message_bus_id_seq'::regclass);
--
-- Name: metrics id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.metrics ALTER COLUMN id SET DEFAULT nextval('public.metrics_id_seq'::regclass);
--
-- Name: models id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.models ALTER COLUMN id SET DEFAULT nextval('public.models_id_seq'::regclass);
--
-- Name: notifications id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('public.notifications_id_seq'::regclass);
--
-- Name: providers id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.providers ALTER COLUMN id SET DEFAULT nextval('public.providers_id_seq'::regclass);
--
-- Name: proxies id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.proxies ALTER COLUMN id SET DEFAULT nextval('public.proxies_id_seq'::regclass);
--
-- Name: que_jobs id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.que_jobs ALTER COLUMN id SET DEFAULT nextval('public.que_jobs_id_seq'::regclass);
--
-- Name: services id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.services ALTER COLUMN id SET DEFAULT nextval('public.services_id_seq'::regclass);
--
-- Name: tenants id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.tenants ALTER COLUMN id SET DEFAULT nextval('public.tenants_id_seq'::regclass);
--
-- Name: update_states id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.update_states ALTER COLUMN id SET DEFAULT nextval('public.update_states_id_seq'::regclass);
--
-- Name: usage_limits id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.usage_limits ALTER COLUMN id SET DEFAULT nextval('public.usage_limits_id_seq'::regclass);
--
-- Name: applications applications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.applications
ADD CONSTRAINT applications_pkey PRIMARY KEY (id);
--
-- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.ar_internal_metadata
ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
--
-- Name: clients clients_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.clients
ADD CONSTRAINT clients_pkey PRIMARY KEY (id);
--
-- Name: entries entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.entries
ADD CONSTRAINT entries_pkey PRIMARY KEY (id);
--
-- Name: integration_states integration_states_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.integration_states
ADD CONSTRAINT integration_states_pkey PRIMARY KEY (id);
--
-- Name: integrations integrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.integrations
ADD CONSTRAINT integrations_pkey PRIMARY KEY (id);
--
-- Name: message_bus message_bus_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.message_bus
ADD CONSTRAINT message_bus_pkey PRIMARY KEY (id);
--
-- Name: metrics metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.metrics
ADD CONSTRAINT metrics_pkey PRIMARY KEY (id);
--
-- Name: models models_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.models
ADD CONSTRAINT models_pkey PRIMARY KEY (id);
--
-- Name: notifications notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.notifications
ADD CONSTRAINT notifications_pkey PRIMARY KEY (id);
--
-- Name: providers providers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.providers
ADD CONSTRAINT providers_pkey PRIMARY KEY (id);
--
-- Name: proxies proxies_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.proxies
ADD CONSTRAINT proxies_pkey PRIMARY KEY (id);