-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcomplete_database_export.sql
More file actions
1198 lines (862 loc) · 64.1 KB
/
Copy pathcomplete_database_export.sql
File metadata and controls
1198 lines (862 loc) · 64.1 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.9
-- Dumped by pg_dump version 16.9
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;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: analytics; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.analytics (
id character varying DEFAULT gen_random_uuid() NOT NULL,
date timestamp without time zone NOT NULL,
messages_sent integer DEFAULT 0,
messages_delivered integer DEFAULT 0,
messages_read integer DEFAULT 0,
messages_replied integer DEFAULT 0,
new_contacts integer DEFAULT 0,
active_campaigns integer DEFAULT 0,
created_at timestamp without time zone DEFAULT now(),
channel_id character varying,
updated_at timestamp without time zone DEFAULT now()
);
--
-- Name: api_logs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.api_logs (
id character varying DEFAULT gen_random_uuid() NOT NULL,
channel_id character varying,
request_type character varying(50) NOT NULL,
endpoint text NOT NULL,
method character varying(10) NOT NULL,
request_body jsonb,
response_status integer,
response_body jsonb,
duration integer,
created_at timestamp without time zone DEFAULT now()
);
--
-- Name: automations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.automations (
id character varying DEFAULT gen_random_uuid() NOT NULL,
name text NOT NULL,
description text,
trigger jsonb NOT NULL,
actions jsonb NOT NULL,
conditions jsonb DEFAULT '[]'::jsonb,
status text DEFAULT 'inactive'::text,
execution_count integer DEFAULT 0,
created_at timestamp without time zone DEFAULT now(),
channel_id character varying,
updated_at timestamp without time zone DEFAULT now()
);
--
-- Name: campaign_recipients; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.campaign_recipients (
id character varying DEFAULT gen_random_uuid() NOT NULL,
campaign_id character varying NOT NULL,
contact_id character varying,
phone text NOT NULL,
name text,
status text DEFAULT 'pending'::text,
whatsapp_message_id character varying,
template_params jsonb DEFAULT '{}'::jsonb,
sent_at timestamp without time zone,
delivered_at timestamp without time zone,
read_at timestamp without time zone,
error_code character varying,
error_message text,
retry_count integer DEFAULT 0,
created_at timestamp without time zone DEFAULT now(),
updated_at timestamp without time zone DEFAULT now()
);
--
-- Name: campaigns; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.campaigns (
id character varying DEFAULT gen_random_uuid() NOT NULL,
name text NOT NULL,
description text,
type text NOT NULL,
api_type text NOT NULL,
template_id character varying,
recipients jsonb DEFAULT '[]'::jsonb,
status text DEFAULT 'draft'::text,
scheduled_at timestamp without time zone,
sent_count integer DEFAULT 0,
delivered_count integer DEFAULT 0,
read_count integer DEFAULT 0,
replied_count integer DEFAULT 0,
failed_count integer DEFAULT 0,
created_at timestamp without time zone DEFAULT now(),
channel_id character varying,
recipient_count integer DEFAULT 0,
completed_at timestamp without time zone,
updated_at timestamp without time zone DEFAULT now(),
campaign_type text,
template_name text,
template_language text,
variable_mapping jsonb DEFAULT '{}'::jsonb,
contact_groups jsonb DEFAULT '[]'::jsonb,
csv_data jsonb DEFAULT '[]'::jsonb,
api_key character varying(255),
api_endpoint text
);
--
-- Name: channels; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.channels (
id character varying DEFAULT gen_random_uuid() NOT NULL,
name text NOT NULL,
phone_number_id text NOT NULL,
access_token text NOT NULL,
whatsapp_business_account_id text,
phone_number text,
is_active boolean DEFAULT true,
created_at timestamp without time zone DEFAULT now(),
updated_at timestamp without time zone DEFAULT now(),
mm_lite_enabled boolean DEFAULT false,
mm_lite_api_url text,
mm_lite_api_key text,
health_status text DEFAULT 'unknown'::text,
last_health_check timestamp without time zone,
health_details jsonb DEFAULT '{}'::jsonb
);
--
-- Name: contacts; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.contacts (
id character varying DEFAULT gen_random_uuid() NOT NULL,
name text NOT NULL,
phone text NOT NULL,
email text,
groups jsonb DEFAULT '[]'::jsonb,
tags jsonb DEFAULT '[]'::jsonb,
status text DEFAULT 'active'::text,
last_contact timestamp without time zone,
created_at timestamp without time zone DEFAULT now(),
channel_id character varying,
updated_at timestamp without time zone DEFAULT now()
);
--
-- Name: conversation_assignments; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.conversation_assignments (
id character varying DEFAULT gen_random_uuid() NOT NULL,
conversation_id character varying NOT NULL,
team_member_id character varying NOT NULL,
assigned_by character varying,
assigned_at timestamp without time zone DEFAULT now(),
status text DEFAULT 'active'::text NOT NULL,
priority text DEFAULT 'normal'::text,
notes text,
resolved_at timestamp without time zone,
created_at timestamp without time zone DEFAULT now(),
updated_at timestamp without time zone DEFAULT now()
);
--
-- Name: conversations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.conversations (
id character varying DEFAULT gen_random_uuid() NOT NULL,
contact_id character varying NOT NULL,
assigned_to character varying,
status text DEFAULT 'open'::text,
priority text DEFAULT 'normal'::text,
tags jsonb DEFAULT '[]'::jsonb,
last_message_at timestamp without time zone,
created_at timestamp without time zone DEFAULT now(),
contact_phone character varying,
contact_name character varying,
unread_count integer DEFAULT 0,
channel_id character varying,
updated_at timestamp without time zone DEFAULT now(),
last_message_text text
);
--
-- Name: message_queue; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.message_queue (
id character varying DEFAULT gen_random_uuid() NOT NULL,
campaign_id character varying,
channel_id character varying,
recipient_phone character varying(20) NOT NULL,
template_name character varying(100),
template_params jsonb DEFAULT '[]'::jsonb,
message_type character varying(20) NOT NULL,
status character varying(20) DEFAULT 'queued'::character varying,
attempts integer DEFAULT 0,
whatsapp_message_id character varying(100),
conversation_id character varying(100),
sent_via character varying(20),
cost character varying(20),
error_code character varying(50),
error_message text,
scheduled_for timestamp without time zone,
processed_at timestamp without time zone,
delivered_at timestamp without time zone,
read_at timestamp without time zone,
created_at timestamp without time zone DEFAULT now()
);
--
-- Name: messages; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.messages (
id character varying DEFAULT gen_random_uuid() NOT NULL,
conversation_id character varying NOT NULL,
from_user boolean DEFAULT false,
content text NOT NULL,
type text DEFAULT 'text'::text,
status text DEFAULT 'sent'::text,
created_at timestamp without time zone DEFAULT now(),
whatsapp_message_id character varying,
direction character varying DEFAULT 'outbound'::character varying,
message_type character varying,
"timestamp" timestamp without time zone,
metadata jsonb DEFAULT '{}'::jsonb,
delivered_at timestamp without time zone,
read_at timestamp without time zone,
error_code character varying(50),
error_message text,
updated_at timestamp without time zone DEFAULT now(),
error_details jsonb,
campaign_id character varying
);
--
-- Name: session; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.session (
sid character varying NOT NULL,
sess json NOT NULL,
expire timestamp(6) without time zone NOT NULL
);
--
-- Name: team_activity_logs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.team_activity_logs (
id character varying DEFAULT gen_random_uuid() NOT NULL,
team_member_id character varying NOT NULL,
action text NOT NULL,
entity_type text,
entity_id character varying,
details jsonb DEFAULT '{}'::jsonb,
ip_address text,
user_agent text,
created_at timestamp without time zone DEFAULT now()
);
--
-- Name: team_members; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.team_members (
id character varying DEFAULT gen_random_uuid() NOT NULL,
user_id character varying,
name text NOT NULL,
email text NOT NULL,
phone text,
role text DEFAULT 'agent'::text NOT NULL,
status text DEFAULT 'active'::text NOT NULL,
permissions jsonb DEFAULT '{}'::jsonb,
avatar text,
department text,
last_active timestamp without time zone,
online_status text DEFAULT 'offline'::text,
created_at timestamp without time zone DEFAULT now(),
updated_at timestamp without time zone DEFAULT now()
);
--
-- Name: templates; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.templates (
id character varying DEFAULT gen_random_uuid() NOT NULL,
name text NOT NULL,
category text NOT NULL,
language text DEFAULT 'en_US'::text,
header text,
body text NOT NULL,
footer text,
buttons jsonb DEFAULT '[]'::jsonb,
variables jsonb DEFAULT '[]'::jsonb,
status text DEFAULT 'draft'::text,
usage_count integer DEFAULT 0,
created_at timestamp without time zone DEFAULT now(),
channel_id character varying,
media_type text DEFAULT 'text'::text,
media_url text,
media_handle text,
carousel_cards jsonb DEFAULT '[]'::jsonb,
whatsapp_template_id text,
updated_at timestamp without time zone DEFAULT now(),
rejection_reason text
);
--
-- Name: user_activity_logs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.user_activity_logs (
id character varying(255) DEFAULT gen_random_uuid() NOT NULL,
user_id character varying(255) NOT NULL,
action character varying(100) NOT NULL,
entity_type character varying(50),
entity_id character varying(255),
details jsonb DEFAULT '{}'::jsonb,
ip_address character varying(45),
user_agent text,
created_at timestamp without time zone DEFAULT now()
);
--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.users (
id character varying DEFAULT gen_random_uuid() NOT NULL,
username text NOT NULL,
password text NOT NULL,
email text,
first_name text,
last_name text,
role text DEFAULT 'admin'::text,
created_at timestamp without time zone DEFAULT now(),
status character varying(20) DEFAULT 'active'::character varying,
permissions text[] DEFAULT '{}'::text[],
avatar character varying(255),
last_login timestamp without time zone,
updated_at timestamp without time zone DEFAULT now()
);
--
-- Name: webhook_configs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.webhook_configs (
id character varying DEFAULT gen_random_uuid() NOT NULL,
channel_id character varying,
webhook_url text NOT NULL,
verify_token character varying(100) NOT NULL,
app_secret text,
events jsonb DEFAULT '[]'::jsonb NOT NULL,
is_active boolean DEFAULT true,
last_ping_at timestamp without time zone,
created_at timestamp without time zone DEFAULT now()
);
--
-- Name: whatsapp_channels; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.whatsapp_channels (
id character varying DEFAULT gen_random_uuid() NOT NULL,
name text NOT NULL,
phone_number character varying(20) NOT NULL,
phone_number_id character varying(50) NOT NULL,
waba_id character varying(50) NOT NULL,
access_token text NOT NULL,
business_account_id character varying(50),
mm_lite_enabled boolean DEFAULT false,
rate_limit_tier character varying(20) DEFAULT 'standard'::character varying,
quality_rating character varying(20) DEFAULT 'green'::character varying,
status character varying(20) DEFAULT 'inactive'::character varying,
created_at timestamp without time zone DEFAULT now(),
updated_at timestamp without time zone DEFAULT now(),
error_message text,
last_health_check timestamp without time zone,
message_limit integer,
messages_used integer
);
--
-- Name: analytics analytics_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.analytics
ADD CONSTRAINT analytics_pkey PRIMARY KEY (id);
--
-- Name: api_logs api_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.api_logs
ADD CONSTRAINT api_logs_pkey PRIMARY KEY (id);
--
-- Name: automations automations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.automations
ADD CONSTRAINT automations_pkey PRIMARY KEY (id);
--
-- Name: campaign_recipients campaign_recipients_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.campaign_recipients
ADD CONSTRAINT campaign_recipients_pkey PRIMARY KEY (id);
--
-- Name: campaigns campaigns_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.campaigns
ADD CONSTRAINT campaigns_pkey PRIMARY KEY (id);
--
-- Name: channels channels_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.channels
ADD CONSTRAINT channels_pkey PRIMARY KEY (id);
--
-- Name: contacts contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.contacts
ADD CONSTRAINT contacts_pkey PRIMARY KEY (id);
--
-- Name: conversation_assignments conversation_assignments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.conversation_assignments
ADD CONSTRAINT conversation_assignments_pkey PRIMARY KEY (id);
--
-- Name: conversations conversations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.conversations
ADD CONSTRAINT conversations_pkey PRIMARY KEY (id);
--
-- Name: message_queue message_queue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.message_queue
ADD CONSTRAINT message_queue_pkey PRIMARY KEY (id);
--
-- Name: messages messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.messages
ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
--
-- Name: session session_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.session
ADD CONSTRAINT session_pkey PRIMARY KEY (sid);
--
-- Name: team_activity_logs team_activity_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.team_activity_logs
ADD CONSTRAINT team_activity_logs_pkey PRIMARY KEY (id);
--
-- Name: team_members team_members_email_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.team_members
ADD CONSTRAINT team_members_email_key UNIQUE (email);
--
-- Name: team_members team_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.team_members
ADD CONSTRAINT team_members_pkey PRIMARY KEY (id);
--
-- Name: templates templates_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.templates
ADD CONSTRAINT templates_pkey PRIMARY KEY (id);
--
-- Name: user_activity_logs user_activity_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_activity_logs
ADD CONSTRAINT user_activity_logs_pkey PRIMARY KEY (id);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: users users_username_unique; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_username_unique UNIQUE (username);
--
-- Name: webhook_configs webhook_configs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.webhook_configs
ADD CONSTRAINT webhook_configs_pkey PRIMARY KEY (id);
--
-- Name: whatsapp_channels whatsapp_channels_phone_number_unique; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.whatsapp_channels
ADD CONSTRAINT whatsapp_channels_phone_number_unique UNIQUE (phone_number);
--
-- Name: whatsapp_channels whatsapp_channels_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.whatsapp_channels
ADD CONSTRAINT whatsapp_channels_pkey PRIMARY KEY (id);
--
-- Name: IDX_session_expire; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX "IDX_session_expire" ON public.session USING btree (expire);
--
-- Name: campaigns_channel_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX campaigns_channel_idx ON public.campaigns USING btree (channel_id);
--
-- Name: campaigns_created_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX campaigns_created_idx ON public.campaigns USING btree (created_at);
--
-- Name: campaigns_status_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX campaigns_status_idx ON public.campaigns USING btree (status);
--
-- Name: contacts_channel_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX contacts_channel_idx ON public.contacts USING btree (channel_id);
--
-- Name: contacts_phone_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX contacts_phone_idx ON public.contacts USING btree (phone);
--
-- Name: contacts_status_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX contacts_status_idx ON public.contacts USING btree (status);
--
-- Name: conv_assignments_conv_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX conv_assignments_conv_idx ON public.conversation_assignments USING btree (conversation_id);
--
-- Name: conv_assignments_member_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX conv_assignments_member_idx ON public.conversation_assignments USING btree (team_member_id);
--
-- Name: conv_assignments_status_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX conv_assignments_status_idx ON public.conversation_assignments USING btree (status);
--
-- Name: conversations_channel_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX conversations_channel_idx ON public.conversations USING btree (channel_id);
--
-- Name: conversations_contact_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX conversations_contact_idx ON public.conversations USING btree (contact_id);
--
-- Name: conversations_phone_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX conversations_phone_idx ON public.conversations USING btree (contact_phone);
--
-- Name: conversations_status_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX conversations_status_idx ON public.conversations USING btree (status);
--
-- Name: idx_user_activity_logs_action; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx_user_activity_logs_action ON public.user_activity_logs USING btree (action);
--
-- Name: idx_user_activity_logs_created_at; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx_user_activity_logs_created_at ON public.user_activity_logs USING btree (created_at);
--
-- Name: idx_user_activity_logs_user_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx_user_activity_logs_user_id ON public.user_activity_logs USING btree (user_id);
--
-- Name: messages_conversation_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX messages_conversation_idx ON public.messages USING btree (conversation_id);
--
-- Name: messages_created_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX messages_created_idx ON public.messages USING btree (created_at);
--
-- Name: messages_direction_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX messages_direction_idx ON public.messages USING btree (direction);
--
-- Name: messages_status_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX messages_status_idx ON public.messages USING btree (status);
--
-- Name: messages_timestamp_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX messages_timestamp_idx ON public.messages USING btree ("timestamp");
--
-- Name: messages_whatsapp_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX messages_whatsapp_idx ON public.messages USING btree (whatsapp_message_id);
--
-- Name: recipients_campaign_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX recipients_campaign_idx ON public.campaign_recipients USING btree (campaign_id);
--
-- Name: recipients_phone_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX recipients_phone_idx ON public.campaign_recipients USING btree (phone);
--
-- Name: recipients_status_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX recipients_status_idx ON public.campaign_recipients USING btree (status);
--
-- Name: team_logs_action_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX team_logs_action_idx ON public.team_activity_logs USING btree (action);
--
-- Name: team_logs_created_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX team_logs_created_idx ON public.team_activity_logs USING btree (created_at);
--
-- Name: team_logs_member_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX team_logs_member_idx ON public.team_activity_logs USING btree (team_member_id);
--
-- Name: team_members_email_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX team_members_email_idx ON public.team_members USING btree (email);
--
-- Name: team_members_status_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX team_members_status_idx ON public.team_members USING btree (status);
--
-- Name: team_members_user_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX team_members_user_idx ON public.team_members USING btree (user_id);
--
-- Name: api_logs api_logs_channel_id_whatsapp_channels_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.api_logs
ADD CONSTRAINT api_logs_channel_id_whatsapp_channels_id_fk FOREIGN KEY (channel_id) REFERENCES public.whatsapp_channels(id);
--
-- Name: conversation_assignments conversation_assignments_assigned_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.conversation_assignments
ADD CONSTRAINT conversation_assignments_assigned_by_fkey FOREIGN KEY (assigned_by) REFERENCES public.team_members(id);
--
-- Name: conversation_assignments conversation_assignments_conversation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.conversation_assignments
ADD CONSTRAINT conversation_assignments_conversation_id_fkey FOREIGN KEY (conversation_id) REFERENCES public.conversations(id) ON DELETE CASCADE;
--
-- Name: conversation_assignments conversation_assignments_team_member_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.conversation_assignments
ADD CONSTRAINT conversation_assignments_team_member_id_fkey FOREIGN KEY (team_member_id) REFERENCES public.team_members(id) ON DELETE CASCADE;
--
-- Name: campaign_recipients fk_campaign_recipients_campaign; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.campaign_recipients
ADD CONSTRAINT fk_campaign_recipients_campaign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE;
--
-- Name: message_queue message_queue_campaign_id_campaigns_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.message_queue
ADD CONSTRAINT message_queue_campaign_id_campaigns_id_fk FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id);
--
-- Name: message_queue message_queue_channel_id_whatsapp_channels_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.message_queue
ADD CONSTRAINT message_queue_channel_id_whatsapp_channels_id_fk FOREIGN KEY (channel_id) REFERENCES public.whatsapp_channels(id);
--
-- Name: messages messages_campaign_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.messages
ADD CONSTRAINT messages_campaign_id_fkey FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE SET NULL;
--
-- Name: team_activity_logs team_activity_logs_team_member_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.team_activity_logs
ADD CONSTRAINT team_activity_logs_team_member_id_fkey FOREIGN KEY (team_member_id) REFERENCES public.team_members(id) ON DELETE CASCADE;
--
-- Name: team_members team_members_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.team_members
ADD CONSTRAINT team_members_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: templates templates_channel_id_channels_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.templates
ADD CONSTRAINT templates_channel_id_channels_id_fk FOREIGN KEY (channel_id) REFERENCES public.channels(id);
--
-- Name: user_activity_logs user_activity_logs_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_activity_logs
ADD CONSTRAINT user_activity_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- PostgreSQL database dump complete
--
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.9
-- Dumped by pg_dump version 16.9
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;
--
-- Data for Name: analytics; Type: TABLE DATA; Schema: public; Owner: -
--
--
-- Data for Name: whatsapp_channels; Type: TABLE DATA; Schema: public; Owner: -
--
INSERT INTO public.whatsapp_channels VALUES ('d420e261-9c12-4cee-9d65-253cda8ab4bc', 'Test', '+15551017536', '153851904474202', '152578724602116', 'EAAJcBVwZAYfoBPNZCHBBWBh4lNLt0SuU8JklS8Y4tVZAaQb4d0gHJeNj4qweITRCOunoSbHm0SzuvC1gc9rhamYI66p72SbFfJIvFz2DTos5ipVYYip1jJmbDWkjuqCH9KVZBKKU8I5DLjFSB0lSwdeY8kxzyMgxkLOgZAxpC7lFUTLhy47N9xgs6eRA4uz0BjYdnOVw9hYByYcFcEO6Eq4IaUUd7fwxyZAKN57jVY2UgMsVfI', '', true, 'standard', 'green', 'active', '2025-08-02 08:07:18.941927', '2025-08-02 08:07:36.994', NULL, '2025-08-02 08:07:36.994', NULL, NULL);
--
-- Data for Name: api_logs; Type: TABLE DATA; Schema: public; Owner: -
--
INSERT INTO public.api_logs VALUES ('66424dff-54bd-4b8f-a22c-31dc632fc5f9', 'd420e261-9c12-4cee-9d65-253cda8ab4bc', 'send_message', 'https://graph.facebook.com/v18.0/153851904474202/messages', 'POST', '{"to": "919310797700", "type": "template", "template": {"name": "hello_world", "language": {"code": "en_US"}}, "recipient_type": "individual", "messaging_product": "whatsapp"}', 200, '{"contacts": [{"input": "919310797700", "wa_id": "919310797700"}], "messages": [{"id": "wamid.HBgMOTE5MzEwNzk3NzAwFQIAERgSMTc5RUQwNUY0ODBDN0FERUIxAA==", "message_status": "accepted"}], "messaging_product": "whatsapp"}', 1005, '2025-08-02 08:07:36.836145');
INSERT INTO public.api_logs VALUES ('d69647ef-74ae-440c-ad8f-9d0e7c987715', 'd420e261-9c12-4cee-9d65-253cda8ab4bc', 'test_connection', 'https://graph.facebook.com/v22.0/153851904474202/messages', 'POST', '{"to": "919310797700", "type": "template", "template": {"name": "hello_world", "language": {"code": "en_US"}}, "messaging_product": "whatsapp"}', 200, '{"contacts": [{"input": "919310797700", "wa_id": "919310797700"}], "messages": [{"id": "wamid.HBgMOTE5MzEwNzk3NzAwFQIAERgSMTc5RUQwNUY0ODBDN0FERUIxAA==", "message_status": "accepted"}], "messaging_product": "whatsapp"}', 0, '2025-08-02 08:07:36.942611');
INSERT INTO public.api_logs VALUES ('d8e6d31c-48ef-4042-8135-eeba9480f56d', 'd420e261-9c12-4cee-9d65-253cda8ab4bc', 'send_message', 'https://graph.facebook.com/v23.0/153851904474202/messages', 'POST', '{"to": "+919310797700", "text": {"body": "test"}, "type": "text", "recipient_type": "individual", "messaging_product": "whatsapp"}', 401, '{"error": {"code": 190, "type": "OAuthException", "message": "Error validating access token: Session has expired on Saturday, 02-Aug-25 02:00:00 PDT. The current time is Saturday, 02-Aug-25 02:17:25 PDT.", "fbtrace_id": "Aohb9L9HQ7wANNZnq-t_kJK", "error_subcode": 463}}', 224, '2025-08-02 09:17:26.155532');
INSERT INTO public.api_logs VALUES ('4bc5f0cc-56ed-445a-b364-7788eaade80b', 'd420e261-9c12-4cee-9d65-253cda8ab4bc', 'send_message', 'https://graph.facebook.com/v23.0/153851904474202/messages', 'POST', '{"to": "+919310797700", "text": {"body": "Test"}, "type": "text", "recipient_type": "individual", "messaging_product": "whatsapp"}', 401, '{"error": {"code": 190, "type": "OAuthException", "message": "Error validating access token: Session has expired on Saturday, 02-Aug-25 02:00:00 PDT. The current time is Saturday, 02-Aug-25 03:35:03 PDT.", "fbtrace_id": "AU2GDoms7Xp-K35uB7oene_", "error_subcode": 463}}', 138, '2025-08-02 10:35:03.366945');
INSERT INTO public.api_logs VALUES ('77974844-2871-4f9c-bd1b-33b63bd601e9', 'd420e261-9c12-4cee-9d65-253cda8ab4bc', 'send_message', 'https://graph.facebook.com/v23.0/153851904474202/messages', 'POST', '{"to": "+919310797700", "text": {"body": "Test"}, "type": "text", "recipient_type": "individual", "messaging_product": "whatsapp"}', 401, '{"error": {"code": 190, "type": "OAuthException", "message": "Error validating access token: Session has expired on Saturday, 02-Aug-25 02:00:00 PDT. The current time is Saturday, 02-Aug-25 03:35:12 PDT.", "fbtrace_id": "Avv9nrbwYiDyRJeRs3zrgqB", "error_subcode": 463}}', 92, '2025-08-02 10:35:12.578754');
INSERT INTO public.api_logs VALUES ('dd0f09fa-ab65-477c-8ebc-9d6c5ad33a7e', 'd420e261-9c12-4cee-9d65-253cda8ab4bc', 'send_message', 'https://graph.facebook.com/v23.0/153851904474202/messages', 'POST', '{"to": "+919310797700", "text": {"body": "Test"}, "type": "text", "recipient_type": "individual", "messaging_product": "whatsapp"}', 401, '{"error": {"code": 190, "type": "OAuthException", "message": "Error validating access token: Session has expired on Saturday, 02-Aug-25 02:00:00 PDT. The current time is Saturday, 02-Aug-25 03:35:23 PDT.", "fbtrace_id": "Ar73rKMjfDyVjGiYOJJbUXb", "error_subcode": 463}}', 91, '2025-08-02 10:35:23.692367');
--
-- Data for Name: automations; Type: TABLE DATA; Schema: public; Owner: -
--
--
-- Data for Name: campaigns; Type: TABLE DATA; Schema: public; Owner: -
--
INSERT INTO public.campaigns VALUES ('eb3edf54-cd25-40d8-ae20-27f398adef6f', 'Friday Sale', 'Demo', 'marketing', 'mm_lite', 'da0d30d1-6f56-477d-bce1-4d60c7e79f1b', '[]', 'active', NULL, 0, 0, 0, 0, 1, '2025-08-03 10:13:47.115195', 'f8e8f949-a099-47e7-a999-94774a6890ab', 3, NULL, '2025-08-03 10:13:47.115195', 'contacts', 'welcome', 'en_US', '{}', '["62535089-4404-459e-a4b1-acb704769856", "b0ba7793-d640-4295-9a98-1c963c5c76da", "646b6db5-0452-4992-8a8f-e54feb18bec5"]', '[]', NULL, NULL);
INSERT INTO public.campaigns VALUES ('a69b818e-e823-4295-87ce-2019511b699a', 'Test-1', 'test', 'marketing', 'mm_lite', 'da0d30d1-6f56-477d-bce1-4d60c7e79f1b', '[]', 'completed', NULL, 2, 0, 0, 0, 0, '2025-08-02 21:36:39.586624', 'f8e8f949-a099-47e7-a999-94774a6890ab', 2, '2025-08-02 21:40:10.585', '2025-08-02 21:36:39.586624', 'contacts', 'welcome', 'en_US', '{}', '["e1a9cc3f-f47c-4178-8cc2-08e6626ae766", "513e2fde-d8bb-4afd-a60a-50a752c60110"]', '[]', NULL, NULL);
INSERT INTO public.campaigns VALUES ('0223a6f4-3807-4406-b709-2e18e9e0d33b', 'cam-2', '', 'marketing', 'mm_lite', '8824aeb5-eb86-4ba9-bd4d-cca4e353b3c9', '[]', 'completed', NULL, 0, 0, 0, 0, 0, '2025-08-02 21:50:40.429775', 'f8e8f949-a099-47e7-a999-94774a6890ab', 0, '2025-08-02 21:50:40.893', '2025-08-02 21:50:40.429775', 'api', 'hello_world', 'en', '{"1": "name"}', '[]', '[]', 'ww_f38265f2fd1c40bf9ad0a251986a55a2', 'http://d6a63d6e-5577-4d02-80b7-0b54ffbd5ab5-00-3ci9wfzjd76hb.worf.replit.dev/api/campaigns/send/ww_f38265f2fd1c40bf9ad0a251986a55a2');
INSERT INTO public.campaigns VALUES ('8317fc19-b241-4c12-9848-a244f8a4dfe8', 'API', '', 'marketing', 'mm_lite', 'da0d30d1-6f56-477d-bce1-4d60c7e79f1b', '[]', 'completed', NULL, 0, 0, 0, 0, 0, '2025-08-02 21:58:55.811185', 'f8e8f949-a099-47e7-a999-94774a6890ab', 0, '2025-08-02 21:58:56.278', '2025-08-02 21:58:55.811185', 'api', 'welcome', 'en_US', '{}', '[]', '[]', 'ww_4e6e77b61c4b44a1bf29a70897b024d8', 'http://d6a63d6e-5577-4d02-80b7-0b54ffbd5ab5-00-3ci9wfzjd76hb.worf.replit.dev/api/campaigns/send/ww_4e6e77b61c4b44a1bf29a70897b024d8');
INSERT INTO public.campaigns VALUES ('f551fc0e-db18-46d2-b313-e6f416c24f91', 'cam-2', '', 'marketing', 'mm_lite', 'da0d30d1-6f56-477d-bce1-4d60c7e79f1b', '[]', 'active', NULL, 0, 0, 0, 0, 1, '2025-08-02 21:49:58.543029', 'f8e8f949-a099-47e7-a999-94774a6890ab', 2, NULL, '2025-08-02 21:49:58.543029', 'contacts', 'welcome', 'en_US', '{}', '["646b6db5-0452-4992-8a8f-e54feb18bec5"]', '[]', NULL, NULL);
--
-- Data for Name: campaign_recipients; Type: TABLE DATA; Schema: public; Owner: -
--
--