forked from etusdigital/open-bms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
2211 lines (1947 loc) · 73.9 KB
/
Copy pathschema.sql
File metadata and controls
2211 lines (1947 loc) · 73.9 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
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.3
-- Dumped by pg_dump version 16.3 (Homebrew)
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: google_vacuum_mgmt; Type: SCHEMA; Schema: -; Owner: -
--
CREATE SCHEMA google_vacuum_mgmt;
--
-- Name: partman; Type: SCHEMA; Schema: -; Owner: -
--
CREATE SCHEMA partman;
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--
-- *not* creating schema, since initdb creates it
--
-- Name: btree_gin; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS btree_gin WITH SCHEMA public;
--
-- Name: EXTENSION btree_gin; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION btree_gin IS 'support for indexing common datatypes in GIN';
--
-- Name: google_vacuum_mgmt; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS google_vacuum_mgmt WITH SCHEMA google_vacuum_mgmt;
--
-- Name: EXTENSION google_vacuum_mgmt; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION google_vacuum_mgmt IS 'extension for assistive operational tooling';
--
-- Name: pg_partman; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_partman WITH SCHEMA partman;
--
-- Name: EXTENSION pg_partman; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION pg_partman IS 'Extension to manage partitioned tables by time or ID';
--
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
--
-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed';
--
-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
--
-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
--
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
--
-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions';
--
-- Name: postgres_fdw; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS postgres_fdw WITH SCHEMA public;
--
-- Name: EXTENSION postgres_fdw; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION postgres_fdw IS 'foreign-data wrapper for remote PostgreSQL servers';
--
-- Name: events_logs_bridge; Type: SERVER; Schema: -; Owner: -
--
CREATE SERVER events_logs_bridge FOREIGN DATA WRAPPER postgres_fdw OPTIONS (
dbname 'msgops_events',
fetch_size '10000',
host 'events-logs.example.internal',
port '5432'
);
--
-- User mappings for the events_logs_bridge FDW server.
-- Add one mapping per local role that needs to read the foreign tables:
-- CREATE USER MAPPING FOR <role> SERVER events_logs_bridge
-- OPTIONS (user '<remote_user>', password '<remote_password>');
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: template_public_contacts; Type: TABLE; Schema: partman; Owner: -
--
CREATE TABLE partman.template_public_contacts (
id integer NOT NULL,
account_id integer NOT NULL,
email character varying(255) NOT NULL,
email_provider character varying(255) NOT NULL,
first_name character varying(255) NOT NULL,
last_name character varying(255),
hashed_email character varying(255) NOT NULL,
phone character varying(255),
city character varying(255),
region character varying(255),
country character varying(255),
postal character varying(255),
ip character varying(50),
latitude numeric(10, 7),
longitude numeric(10, 7),
timezone character varying(100),
is_active boolean NOT NULL,
is_unsubscribed boolean NOT NULL,
has_bounced boolean NOT NULL,
last_open timestamp with time zone,
last_click timestamp with time zone,
last_sent timestamp with time zone,
score integer,
score_forecast integer,
created_at timestamp with time zone NOT NULL,
created_at_date date NOT NULL,
updated_at timestamp with time zone,
last_automation timestamp with time zone,
uuid character varying(40)
);
--
-- Name: template_public_contacts_automations; Type: TABLE; Schema: partman; Owner: -
--
CREATE TABLE partman.template_public_contacts_automations (
id integer NOT NULL,
account_id integer NOT NULL,
contact_id integer NOT NULL,
status character varying(255),
automation_id integer,
automation_title character varying(255),
automation_type character varying(100),
created_at timestamp with time zone NOT NULL,
created_at_date date NOT NULL,
updated_at timestamp with time zone
);
--
-- Name: template_public_contacts_custom_fields; Type: TABLE; Schema: partman; Owner: -
--
CREATE TABLE partman.template_public_contacts_custom_fields (
contact_id integer NOT NULL,
custom_field_id integer NOT NULL,
value text NOT NULL,
account_id integer NOT NULL
);
--
-- Name: template_public_contacts_devices; Type: TABLE; Schema: partman; Owner: -
--
CREATE TABLE partman.template_public_contacts_devices (
id integer NOT NULL,
account_id integer NOT NULL,
contact_id integer NOT NULL,
type character varying(40) NOT NULL,
is_active boolean NOT NULL,
token character varying(255) NOT NULL,
is_unsubscribed boolean NOT NULL,
ip character varying(50),
device_type character varying(60),
os character varying(60),
browser character varying(50),
browser_version character varying(50),
resolution character varying(50),
subscription_url character varying(400),
latest_visited_url character varying(400),
last_session timestamp with time zone,
last_sent timestamp with time zone,
last_sent_date date,
last_view timestamp with time zone,
last_view_date date,
last_click timestamp with time zone,
last_click_date date,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone,
last_delivered timestamp with time zone,
last_delivered_date date
);
--
-- Name: template_public_contacts_tags; Type: TABLE; Schema: partman; Owner: -
--
CREATE TABLE partman.template_public_contacts_tags (
contact_id integer NOT NULL,
tag_id integer NOT NULL,
account_id integer NOT NULL
);
--
-- Name: accounts; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.accounts (
id integer NOT NULL,
name character varying(255) NOT NULL,
description text,
settings json,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
deleted_at timestamp with time zone,
is_active boolean DEFAULT true NOT NULL
);
--
-- Name: accounts_configs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.accounts_configs (
account_id integer NOT NULL,
name character varying(255) NOT NULL,
value text NOT NULL,
description text,
is_load_config boolean DEFAULT true NOT NULL
);
--
-- Name: accounts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.accounts_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: accounts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.accounts_id_seq OWNED BY public.accounts.id;
--
-- Name: accounts_usages; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.accounts_usages (
account_id integer NOT NULL,
service character varying(255) NOT NULL,
date date NOT NULL,
count integer NOT NULL
);
--
-- Name: audits; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.audits (
id integer NOT NULL,
account_id integer,
entity character varying(255),
entity_id integer NOT NULL,
type character varying(255),
old_values json,
new_values json,
"user" character varying(600),
ip_address character varying(255),
user_agent character varying(600),
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp without time zone,
deleted_at timestamp without time zone
);
--
-- Name: audits_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.audits_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: audits_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.audits_id_seq OWNED BY public.audits.id;
--
-- Name: automation_message_account; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.automation_message_account (
id integer NOT NULL,
account_id integer,
automation_message_id integer NOT NULL,
test_id character varying(255) NOT NULL,
provider_account_id character varying(255),
provider character varying(20),
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp without time zone,
deleted_at timestamp without time zone
);
--
-- Name: automation_message_account_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.automation_message_account_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: automation_message_account_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.automation_message_account_id_seq OWNED BY public.automation_message_account.id;
--
-- Name: automations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.automations (
id integer NOT NULL,
account_id integer NOT NULL,
title character varying(255) NOT NULL,
name character varying(255),
active boolean DEFAULT true NOT NULL,
audience_id_external integer,
audience_name character varying(255),
message_id integer,
type character varying(50) DEFAULT 'sunset'::character varying NOT NULL,
version character varying(20) DEFAULT 0 NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
deleted_at timestamp with time zone,
steps jsonb,
triggers jsonb,
step_id integer,
count_steps integer,
description text
);
--
-- Name: automations_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.automations_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: automations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.automations_id_seq OWNED BY public.automations.id;
--
-- Name: messages; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.messages (
id integer NOT NULL,
account_id integer NOT NULL,
title character varying(255) NOT NULL,
subject character varying(255),
preview_text character varying(255),
content text NOT NULL,
content_json json,
text text,
from_mail character varying(255),
from_name character varying(255),
is_tested boolean DEFAULT false,
message_id integer,
ippool character varying(255),
reply_to character varying(255),
priority character varying(20) DEFAULT 'normal'::character varying,
bucket_name character varying(255),
file_name text,
template_url character varying(350),
version integer,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
deleted_at timestamp with time zone,
type character varying(255),
name character varying(255),
image character varying(500),
url character varying(500),
description text,
expiry_push_in_seconds integer,
expiry_push_filter character varying(20),
status character varying(50),
whatsapp_type character varying(50),
call_to_action_text character varying(100),
provider_message_id character varying(100)
);
--
-- Name: automations_message_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.automations_message_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: automations_message_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.automations_message_id_seq OWNED BY public.messages.id;
--
-- Name: campaigns; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.campaigns (
id integer NOT NULL,
account_id integer NOT NULL,
title character varying(255) NOT NULL,
name character varying(255) NOT NULL,
publisher character varying(100) NOT NULL,
schedule_to timestamp with time zone NOT NULL,
schedule_to_cloud_task_id character varying(255),
tags jsonb,
status integer,
spread_sending integer DEFAULT 0 NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
deleted_at timestamp with time zone,
sent_contacts integer,
sent_percentage numeric,
query text,
steps jsonb,
type character varying(30),
testab_schedule_to timestamp with time zone,
testab_schedule_end timestamp with time zone,
testab_audience_percent integer,
testab_criteria character varying(255),
testab_sent_after_test boolean DEFAULT false NOT NULL,
testab_schedule_to_cloud_task_id character varying(255),
testab_schedule_end_cloud_task_id character varying(255),
testab_last_id integer,
message_type character varying(30),
send_to_all boolean DEFAULT false,
description text,
recurrence_count integer DEFAULT 0,
recurrence_settings jsonb,
is_warmup boolean DEFAULT false NOT NULL
);
--
-- Name: campaigns_contacts; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.campaigns_contacts (
campaign_id integer NOT NULL,
contact_id integer NOT NULL
);
--
-- Name: campaigns_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.campaigns_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: campaigns_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.campaigns_id_seq OWNED BY public.campaigns.id;
--
-- Name: campaigns_messages; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.campaigns_messages (
campaign_id integer NOT NULL,
message_id integer NOT NULL,
statistics jsonb,
winner boolean,
result_date timestamp without time zone
);
--
-- Name: contacts; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts (
id integer NOT NULL,
account_id integer NOT NULL,
email character varying(255),
email_provider character varying(255),
first_name character varying(255),
last_name character varying(255),
hashed_email character varying(255),
phone character varying(255),
city character varying(255),
region character varying(255),
country character varying(255),
postal character varying(255),
ip character varying(50),
latitude numeric(10, 7),
longitude numeric(10, 7),
timezone character varying(100),
is_active boolean DEFAULT true NOT NULL,
is_unsubscribed boolean DEFAULT false NOT NULL,
has_bounced boolean DEFAULT false NOT NULL,
last_open timestamp with time zone,
last_click timestamp with time zone,
last_sent timestamp with time zone,
score integer,
score_forecast integer,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
created_at_date date DEFAULT CURRENT_DATE NOT NULL,
updated_at timestamp with time zone,
last_automation timestamp with time zone,
uuid character varying(40),
is_valid boolean DEFAULT true NOT NULL,
has_email boolean DEFAULT true NOT NULL,
has_phone boolean DEFAULT false NOT NULL,
has_web_push boolean DEFAULT false NOT NULL,
has_mobile_push boolean DEFAULT false NOT NULL,
last_open_date date,
last_click_date date,
last_sent_date date,
last_automation_date date,
whatsapp character varying(255),
has_whatsapp boolean DEFAULT false NOT NULL,
whatsapp_last_sent date,
whatsapp_last_delivered date,
whatsapp_last_open date,
whatsapp_last_click date,
sms_last_sent date,
sms_last_delivered date,
sms_last_click date,
has_push_app boolean DEFAULT false
) PARTITION BY RANGE (account_id);
--
-- Name: contacts_automations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts_automations (
id integer NOT NULL,
account_id integer NOT NULL,
contact_id integer NOT NULL,
status character varying(255),
automation_id integer,
automation_title character varying(255),
automation_type character varying(100),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
created_at_date date DEFAULT CURRENT_DATE NOT NULL,
updated_at timestamp with time zone
) PARTITION BY RANGE (account_id);
--
-- Name: contacts_automations_id_seq1; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.contacts_automations_id_seq1 AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: contacts_automations_id_seq1; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.contacts_automations_id_seq1 OWNED BY public.contacts_automations.id;
--
-- Name: contacts_automations_default; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts_automations_default (
id integer DEFAULT nextval('public.contacts_automations_id_seq1'::regclass) NOT NULL,
account_id integer NOT NULL,
contact_id integer NOT NULL,
status character varying(255),
automation_id integer,
automation_title character varying(255),
automation_type character varying(100),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
created_at_date date DEFAULT CURRENT_DATE NOT NULL,
updated_at timestamp with time zone
) WITH (autovacuum_enabled = 'false');
--
-- Name: contacts_custom_fields; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts_custom_fields (
contact_id integer NOT NULL,
custom_field_id integer NOT NULL,
value text NOT NULL,
account_id integer NOT NULL,
"time" timestamp with time zone,
number numeric,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone
) PARTITION BY RANGE (account_id);
--
-- Name: contacts_custom_fields_default; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts_custom_fields_default (
contact_id integer NOT NULL,
custom_field_id integer NOT NULL,
value text NOT NULL,
account_id integer NOT NULL,
"time" timestamp with time zone,
number numeric,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone
) WITH (autovacuum_enabled = 'false');
--
-- Name: contacts_id_seq1; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.contacts_id_seq1 AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: contacts_id_seq1; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.contacts_id_seq1 OWNED BY public.contacts.id;
--
-- Name: contacts_default; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts_default (
id integer DEFAULT nextval('public.contacts_id_seq1'::regclass) NOT NULL,
account_id integer NOT NULL,
email character varying(255),
email_provider character varying(255),
first_name character varying(255),
last_name character varying(255),
hashed_email character varying(255),
phone character varying(255),
city character varying(255),
region character varying(255),
country character varying(255),
postal character varying(255),
ip character varying(50),
latitude numeric(10, 7),
longitude numeric(10, 7),
timezone character varying(100),
is_active boolean DEFAULT true NOT NULL,
is_unsubscribed boolean DEFAULT false NOT NULL,
has_bounced boolean DEFAULT false NOT NULL,
last_open timestamp with time zone,
last_click timestamp with time zone,
last_sent timestamp with time zone,
score integer,
score_forecast integer,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
created_at_date date DEFAULT CURRENT_DATE NOT NULL,
updated_at timestamp with time zone,
last_automation timestamp with time zone,
uuid character varying(40),
is_valid boolean DEFAULT true NOT NULL,
has_email boolean DEFAULT true NOT NULL,
has_phone boolean DEFAULT false NOT NULL,
has_web_push boolean DEFAULT false NOT NULL,
has_mobile_push boolean DEFAULT false NOT NULL,
last_open_date date,
last_click_date date,
last_sent_date date,
last_automation_date date,
whatsapp character varying(255),
has_whatsapp boolean DEFAULT false NOT NULL,
whatsapp_last_sent date,
whatsapp_last_delivered date,
whatsapp_last_open date,
whatsapp_last_click date,
sms_last_sent date,
sms_last_delivered date,
sms_last_click date,
has_push_app boolean DEFAULT false
) WITH (autovacuum_enabled = 'false');
--
-- Name: contacts_devices_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.contacts_devices_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: contacts_devices; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts_devices (
id integer DEFAULT nextval('public.contacts_devices_id_seq'::regclass) NOT NULL,
account_id integer NOT NULL,
contact_id integer NOT NULL,
type character varying(40) NOT NULL,
is_active boolean DEFAULT true NOT NULL,
token character varying(255) NOT NULL,
is_unsubscribed boolean DEFAULT false NOT NULL,
ip character varying(50),
device_type character varying(60),
os character varying(60),
browser character varying(50),
browser_version character varying(50),
resolution character varying(50),
subscription_url character varying(400),
latest_visited_url character varying(400),
last_session timestamp with time zone,
last_sent timestamp with time zone,
last_sent_date date,
last_view timestamp with time zone,
last_view_date date,
last_click timestamp with time zone,
last_click_date date,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone,
last_delivered timestamp with time zone,
last_delivered_date date
) PARTITION BY RANGE (account_id);
--
-- Name: contacts_devices_default; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts_devices_default (
id integer DEFAULT nextval('public.contacts_devices_id_seq'::regclass) NOT NULL,
account_id integer NOT NULL,
contact_id integer NOT NULL,
type character varying(40) NOT NULL,
is_active boolean DEFAULT true NOT NULL,
token character varying(255) NOT NULL,
is_unsubscribed boolean DEFAULT false NOT NULL,
ip character varying(50),
device_type character varying(60),
os character varying(60),
browser character varying(50),
browser_version character varying(50),
resolution character varying(50),
subscription_url character varying(400),
latest_visited_url character varying(400),
last_session timestamp with time zone,
last_sent timestamp with time zone,
last_sent_date date,
last_view timestamp with time zone,
last_view_date date,
last_click timestamp with time zone,
last_click_date date,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone,
last_delivered timestamp with time zone,
last_delivered_date date
);
--
-- Name: contacts_tags; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts_tags (
contact_id integer NOT NULL,
tag_id integer NOT NULL,
account_id integer NOT NULL,
is_active boolean DEFAULT true
) PARTITION BY RANGE (account_id);
--
-- Name: contacts_tags_default; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts_tags_default (
contact_id integer NOT NULL,
tag_id integer NOT NULL,
account_id integer NOT NULL,
is_active boolean DEFAULT true
) WITH (autovacuum_enabled = 'false');
--
-- Name: custom_fields; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.custom_fields (
id integer NOT NULL,
account_id integer NOT NULL,
title character varying(255) NOT NULL,
name character varying(255) NOT NULL,
description text,
"order" integer,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
type character varying(50),
attribution_type character varying(20),
label character varying(255),
placeholder character varying(255),
field_format character varying(255),
file_formats text [],
character_limit integer,
decimal_length integer,
options text [],
mask character varying(255),
field_type character varying(20) DEFAULT 'text'::character varying
);
--
-- Name: custom_fields_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.custom_fields_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: custom_fields_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.custom_fields_id_seq OWNED BY public.custom_fields.id;
--
-- Name: email_validations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.email_validations (
email character varying(255) NOT NULL,
status character varying(50),
reason character varying(255) NOT NULL,
response text NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone
);
--
-- Name: emails_templates; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.emails_templates (
id integer NOT NULL,
account_id integer NOT NULL,
name character varying(255) NOT NULL,
html_template text,
json_template text,
image_template text,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
deleted_at timestamp with time zone,
description text
);
--
-- Name: emails_templates_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.emails_templates_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: emails_templates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.emails_templates_id_seq OWNED BY public.emails_templates.id;
--
-- Name: events_logs; Type: FOREIGN TABLE; Schema: public; Owner: -
--
CREATE FOREIGN TABLE public.events_logs (
"time" timestamp with time zone,
date date,
account_id integer,
message_type character varying(40),
event character varying(40),
contact_id integer,
automation_id integer,
campaign_id integer,
message_id integer,
email character varying,
utm_campaign character varying,
provider character varying,
is_test_ab boolean,
reason character varying(255),
url character varying(500),
ip inet,
events_logs_id bigint NOT NULL
) SERVER events_logs_bridge OPTIONS (
schema_name 'public',
table_name 'events_logs'
);
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN "time" OPTIONS (column_name 'time');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN date OPTIONS (column_name 'date');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN account_id OPTIONS (column_name 'account_id');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN message_type OPTIONS (column_name 'message_type');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN event OPTIONS (column_name 'event');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN contact_id OPTIONS (column_name 'contact_id');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN automation_id OPTIONS (column_name 'automation_id');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN campaign_id OPTIONS (column_name 'campaign_id');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN message_id OPTIONS (column_name 'message_id');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN email OPTIONS (column_name 'email');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN utm_campaign OPTIONS (column_name 'utm_campaign');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN provider OPTIONS (column_name 'provider');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN is_test_ab OPTIONS (column_name 'is_test_ab');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN reason OPTIONS (column_name 'reason');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN url OPTIONS (column_name 'url');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN ip OPTIONS (column_name 'ip');
ALTER FOREIGN TABLE public.events_logs
ALTER COLUMN events_logs_id OPTIONS (column_name 'events_logs_id');
--
-- Name: leads; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.leads (
id bigint NOT NULL,
account_id integer NOT NULL,
contact_id integer NOT NULL,
uuid character varying(255),
transaction_id character varying(100),
email character varying(255),
hashed_email character varying(255),
email_provider character varying(40),
phone character varying(40),
first_name character varying(255),
last_name character varying(255),
city character varying(255),
region character varying(255),
country character varying(255),
ip character varying(50),
latitude numeric(10, 7),
longitude numeric(10, 7),
timezone character varying(100),
clid text,
ad_id text,
adgroup_id text,
adset_id text,
placement text,
campaign_id text,
utm_source text,
utm_medium text,
utm_content text,
utm_campaign text,
utm_term text,
utm_keyword text,
questions jsonb,
forms jsonb,
query_string jsonb,
is_valid boolean DEFAULT false NOT NULL,
invalid_reason text,
lead_source character varying(255),
custom_fields jsonb,
source_url text,
direct_to_url text,
user_agent text,
engaged character varying(50),
status character varying(255),
tag_name character varying(255),
automation_id integer,
automation_title character varying(255),
automation_status character varying(20),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
created_at_date date DEFAULT CURRENT_DATE NOT NULL,
updated_at timestamp with time zone
);
--
-- Name: leads_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.leads_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: leads_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.leads_id_seq OWNED BY public.leads.id;
--
-- Name: migration; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.migration (
id integer NOT NULL,
"timestamp" bigint NOT NULL,
name character varying NOT NULL
);
--
-- Name: migration_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.migration_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: migration_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.migration_id_seq OWNED BY public.migration.id;
--
-- Name: pools; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.pools (
id integer NOT NULL,
account_id integer NOT NULL,
name character varying(255) NOT NULL,
pool_name character varying(255),
ip json,
sending_limit character varying(255),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
deleted_at timestamp with time zone,
sender_email character varying(255),
sender_name character varying(60),
sender_replyto_email character varying(255),
is_default boolean DEFAULT false,
description text,
is_warmup boolean DEFAULT false NOT NULL
);
--
-- Name: pools_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.pools_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
--
-- Name: pools_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.pools_id_seq OWNED BY public.pools.id;
--
-- Name: postmaster; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.postmaster (
"time" bigint NOT NULL,