-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase_dump.sql
More file actions
3020 lines (2045 loc) · 168 KB
/
database_dump.sql
File metadata and controls
3020 lines (2045 loc) · 168 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 17.5 (6bc9ef8)
-- Dumped by pg_dump version 17.5
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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: public; Type: SCHEMA; Schema: -; Owner: neondb_owner
--
-- *not* creating schema, since initdb creates it
ALTER SCHEMA public OWNER TO neondb_owner;
--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: neondb_owner
--
COMMENT ON SCHEMA public IS '';
--
-- Name: topology; Type: SCHEMA; Schema: -; Owner: neondb_owner
--
CREATE SCHEMA topology;
ALTER SCHEMA topology OWNER TO neondb_owner;
--
-- Name: SCHEMA topology; Type: COMMENT; Schema: -; Owner: neondb_owner
--
COMMENT ON SCHEMA topology IS 'PostGIS Topology schema';
--
-- Name: postgis; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
--
-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION postgis IS 'PostGIS geometry and geography spatial types and functions';
--
-- Name: postgis_topology; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS postgis_topology WITH SCHEMA topology;
--
-- Name: EXTENSION postgis_topology; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION postgis_topology IS 'PostGIS topology spatial types and functions';
--
-- Name: activitystatusenum; Type: TYPE; Schema: public; Owner: neondb_owner
--
CREATE TYPE public.activitystatusenum AS ENUM (
'ACTIVE',
'INACTIVE',
'PENDING',
'SUSPENDED'
);
ALTER TYPE public.activitystatusenum OWNER TO neondb_owner;
--
-- Name: interactiontypeenum; Type: TYPE; Schema: public; Owner: neondb_owner
--
CREATE TYPE public.interactiontypeenum AS ENUM (
'SEARCH',
'VIEW',
'CLICK',
'CALL',
'WHATSAPP',
'EMAIL',
'WEBSITE',
'DIRECTION'
);
ALTER TYPE public.interactiontypeenum OWNER TO neondb_owner;
--
-- Name: verificationstatusenum; Type: TYPE; Schema: public; Owner: neondb_owner
--
CREATE TYPE public.verificationstatusenum AS ENUM (
'PENDING',
'APPROVED',
'REJECTED'
);
ALTER TYPE public.verificationstatusenum OWNER TO neondb_owner;
--
-- Name: calculate_distance(numeric, numeric, numeric, numeric); Type: FUNCTION; Schema: public; Owner: neondb_owner
--
CREATE FUNCTION public.calculate_distance(lat1 numeric, lon1 numeric, lat2 numeric, lon2 numeric) RETURNS numeric
LANGUAGE plpgsql
AS $$
BEGIN
RETURN ST_Distance(
ST_SetSRID(ST_MakePoint(lon1, lat1), 4326),
ST_SetSRID(ST_MakePoint(lon2, lat2), 4326)
);
END;
$$;
ALTER FUNCTION public.calculate_distance(lat1 numeric, lon1 numeric, lat2 numeric, lon2 numeric) OWNER TO neondb_owner;
--
-- Name: find_activities_in_radius(numeric, numeric, integer, character varying, integer); Type: FUNCTION; Schema: public; Owner: neondb_owner
--
CREATE FUNCTION public.find_activities_in_radius(user_lat numeric, user_lon numeric, radius_meters integer DEFAULT 5000, activity_type_filter character varying DEFAULT NULL::character varying, category_filter integer DEFAULT NULL::integer) RETURNS TABLE(activity_id integer, name character varying, distance_meters numeric, activity_type character varying, category_name character varying, rating numeric, is_open boolean)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY
SELECT
a.id,
a.name,
ST_Distance(
a.location,
ST_SetSRID(ST_MakePoint(user_lon, user_lat), 4326)
) as distance,
at.name as activity_type,
c.name as category,
a.rating,
a.is_open
FROM activities a
LEFT JOIN activity_types at ON a.activity_type_id = at.id
LEFT JOIN categories c ON a.category_id = c.id
WHERE
a.is_active = TRUE
AND ST_DWithin(
a.location,
ST_SetSRID(ST_MakePoint(user_lon, user_lat), 4326),
radius_meters
)
AND (activity_type_filter IS NULL OR at.slug = activity_type_filter)
AND (category_filter IS NULL OR a.category_id = category_filter)
ORDER BY distance;
END;
$$;
ALTER FUNCTION public.find_activities_in_radius(user_lat numeric, user_lon numeric, radius_meters integer, activity_type_filter character varying, category_filter integer) OWNER TO neondb_owner;
--
-- Name: update_activity_stats(); Type: FUNCTION; Schema: public; Owner: neondb_owner
--
CREATE FUNCTION public.update_activity_stats() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
-- Mettre ├á jour les statistiques de l'activit├®
UPDATE activities
SET
rating = (
SELECT COALESCE(AVG(rating), 0)
FROM reviews
WHERE activity_id = NEW.activity_id AND is_approved = TRUE
),
review_count = (
SELECT COUNT(*)
FROM reviews
WHERE activity_id = NEW.activity_id AND is_approved = TRUE
)
WHERE id = NEW.activity_id;
END IF;
RETURN COALESCE(NEW, OLD);
END;
$$;
ALTER FUNCTION public.update_activity_stats() OWNER TO neondb_owner;
--
-- Name: update_updated_at_column(); Type: FUNCTION; Schema: public; Owner: neondb_owner
--
CREATE FUNCTION public.update_updated_at_column() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$;
ALTER FUNCTION public.update_updated_at_column() OWNER TO neondb_owner;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: activities; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.activities (
id integer NOT NULL,
name character varying(255) NOT NULL,
slug character varying(255) NOT NULL,
description text,
short_description character varying(500),
activity_type_id integer,
category_id integer,
address text,
location public.geometry(Point,4326) NOT NULL,
zone_id integer,
phone_number character varying(20),
whatsapp_number character varying(20),
email character varying(255),
website character varying(500),
is_verified boolean DEFAULT false,
is_active boolean DEFAULT true,
is_open boolean DEFAULT true,
verification_level integer DEFAULT 0,
owner_id integer,
manager_id integer,
ambassador_id integer,
price_level integer DEFAULT 1,
accepts_cash boolean DEFAULT true,
accepts_card boolean DEFAULT false,
accepts_mobile_money boolean DEFAULT false,
opening_hours jsonb DEFAULT '{}'::jsonb,
special_hours jsonb DEFAULT '{}'::jsonb,
rating numeric(3,2) DEFAULT 0.0,
review_count integer DEFAULT 0,
view_count integer DEFAULT 0,
search_count integer DEFAULT 0,
cover_image_url text,
logo_url text,
tags text[],
keywords text[],
languages character varying(10)[],
custom_data jsonb DEFAULT '{}'::jsonb,
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now(),
verified_at timestamp with time zone,
last_activity_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.activities OWNER TO neondb_owner;
--
-- Name: TABLE activities; Type: COMMENT; Schema: public; Owner: neondb_owner
--
COMMENT ON TABLE public.activities IS 'Table principale des activit├®s - remplace merchants pour plus de polyvalence';
--
-- Name: activity_types; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.activity_types (
id integer NOT NULL,
name character varying(100) NOT NULL,
slug character varying(100) NOT NULL,
description text,
category_id integer,
requires_verification boolean DEFAULT false,
allows_online_booking boolean DEFAULT false,
allows_delivery boolean DEFAULT false,
is_public boolean DEFAULT true,
created_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.activity_types OWNER TO neondb_owner;
--
-- Name: TABLE activity_types; Type: COMMENT; Schema: public; Owner: neondb_owner
--
COMMENT ON TABLE public.activity_types IS 'Types d''activit├®s possibles (restaurant, pharmacie, ├®cole, etc.)';
--
-- Name: ambassadors; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.ambassadors (
id integer NOT NULL,
user_id integer,
full_name character varying(255) NOT NULL,
id_document_type character varying(50),
id_document_number character varying(100),
id_document_image_url text,
status character varying(20) DEFAULT 'pending'::character varying,
level integer DEFAULT 1,
points integer DEFAULT 0,
assigned_zones integer[],
max_activities integer DEFAULT 10,
activities_created integer DEFAULT 0,
activities_verified integer DEFAULT 0,
verification_accuracy numeric(3,2) DEFAULT 0.0,
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now(),
approved_at timestamp with time zone
);
ALTER TABLE public.ambassadors OWNER TO neondb_owner;
--
-- Name: categories; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.categories (
id integer NOT NULL,
name character varying(100) NOT NULL,
slug character varying(100) NOT NULL,
description text,
icon character varying(100),
color character varying(7),
parent_id integer,
level integer DEFAULT 0,
is_active boolean DEFAULT true,
sort_order integer DEFAULT 0,
created_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.categories OWNER TO neondb_owner;
--
-- Name: cities; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.cities (
id integer NOT NULL,
region_id integer,
name character varying(100) NOT NULL,
population integer,
geometry public.geometry(MultiPolygon,4326),
center_point public.geometry(Point,4326),
created_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.cities OWNER TO neondb_owner;
--
-- Name: countries; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.countries (
id integer NOT NULL,
name character varying(100) NOT NULL,
code character varying(3) NOT NULL,
currency character varying(3),
timezone character varying(50),
geometry public.geometry(MultiPolygon,4326),
created_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.countries OWNER TO neondb_owner;
--
-- Name: regions; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.regions (
id integer NOT NULL,
country_id integer,
name character varying(100) NOT NULL,
code character varying(10),
geometry public.geometry(MultiPolygon,4326),
created_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.regions OWNER TO neondb_owner;
--
-- Name: users; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.users (
id integer NOT NULL,
phone_number character varying(20) NOT NULL,
email character varying(255),
full_name character varying(255),
avatar_url text,
is_verified boolean DEFAULT false,
is_active boolean DEFAULT true,
last_location public.geometry(Point,4326),
preferred_language character varying(5) DEFAULT 'fr'::character varying,
timezone character varying(50) DEFAULT 'Africa/Abidjan'::character varying,
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now(),
last_seen timestamp with time zone DEFAULT now()
);
ALTER TABLE public.users OWNER TO neondb_owner;
--
-- Name: zones; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.zones (
id integer NOT NULL,
city_id integer,
name character varying(100) NOT NULL,
type character varying(50) DEFAULT 'neighborhood'::character varying,
geometry public.geometry(MultiPolygon,4326),
center_point public.geometry(Point,4326),
population integer,
created_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.zones OWNER TO neondb_owner;
--
-- Name: TABLE zones; Type: COMMENT; Schema: public; Owner: neondb_owner
--
COMMENT ON TABLE public.zones IS 'Zones g├®ographiques pour la localisation et le ciblage';
--
-- Name: activities_full; Type: VIEW; Schema: public; Owner: neondb_owner
--
CREATE VIEW public.activities_full AS
SELECT a.id,
a.name,
a.slug,
a.description,
a.short_description,
a.activity_type_id,
a.category_id,
a.address,
a.location,
a.zone_id,
a.phone_number,
a.whatsapp_number,
a.email,
a.website,
a.is_verified,
a.is_active,
a.is_open,
a.verification_level,
a.owner_id,
a.manager_id,
a.ambassador_id,
a.price_level,
a.accepts_cash,
a.accepts_card,
a.accepts_mobile_money,
a.opening_hours,
a.special_hours,
a.rating,
a.review_count,
a.view_count,
a.search_count,
a.cover_image_url,
a.logo_url,
a.tags,
a.keywords,
a.languages,
a.custom_data,
a.created_at,
a.updated_at,
a.verified_at,
a.last_activity_at,
at.name AS activity_type_name,
at.slug AS activity_type_slug,
c.name AS category_name,
c.slug AS category_slug,
z.name AS zone_name,
z.type AS zone_type,
ci.name AS city_name,
r.name AS region_name,
co.name AS country_name,
u.full_name AS owner_name,
amb.full_name AS ambassador_name,
public.st_x(a.location) AS longitude,
public.st_y(a.location) AS latitude
FROM ((((((((public.activities a
LEFT JOIN public.activity_types at ON ((a.activity_type_id = at.id)))
LEFT JOIN public.categories c ON ((a.category_id = c.id)))
LEFT JOIN public.zones z ON ((a.zone_id = z.id)))
LEFT JOIN public.cities ci ON ((z.city_id = ci.id)))
LEFT JOIN public.regions r ON ((ci.region_id = r.id)))
LEFT JOIN public.countries co ON ((r.country_id = co.id)))
LEFT JOIN public.users u ON ((a.owner_id = u.id)))
LEFT JOIN public.ambassadors amb ON ((a.ambassador_id = amb.user_id)));
ALTER VIEW public.activities_full OWNER TO neondb_owner;
--
-- Name: activities_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.activities_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.activities_id_seq OWNER TO neondb_owner;
--
-- Name: activities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.activities_id_seq OWNED BY public.activities.id;
--
-- Name: activity_types_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.activity_types_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.activity_types_id_seq OWNER TO neondb_owner;
--
-- Name: activity_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.activity_types_id_seq OWNED BY public.activity_types.id;
--
-- Name: ambassadors_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.ambassadors_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.ambassadors_id_seq OWNER TO neondb_owner;
--
-- Name: ambassadors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.ambassadors_id_seq OWNED BY public.ambassadors.id;
--
-- Name: audit_logs; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.audit_logs (
id integer NOT NULL,
user_id integer,
action character varying(100) NOT NULL,
table_name character varying(100),
record_id integer,
old_values jsonb,
new_values jsonb,
ip_address inet,
user_agent text,
session_id character varying(100),
created_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.audit_logs OWNER TO neondb_owner;
--
-- Name: audit_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.audit_logs_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.audit_logs_id_seq OWNER TO neondb_owner;
--
-- Name: audit_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.audit_logs_id_seq OWNED BY public.audit_logs.id;
--
-- Name: categories_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.categories_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.categories_id_seq OWNER TO neondb_owner;
--
-- Name: categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.categories_id_seq OWNED BY public.categories.id;
--
-- Name: cities_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.cities_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.cities_id_seq OWNER TO neondb_owner;
--
-- Name: cities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.cities_id_seq OWNED BY public.cities.id;
--
-- Name: conversations; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.conversations (
id integer NOT NULL,
user_id integer,
session_id character varying(100),
context jsonb DEFAULT '{}'::jsonb,
user_location public.geometry(Point,4326),
status character varying(20) DEFAULT 'active'::character varying,
language character varying(5) DEFAULT 'fr'::character varying,
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now(),
last_message_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.conversations OWNER TO neondb_owner;
--
-- Name: conversations_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.conversations_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.conversations_id_seq OWNER TO neondb_owner;
--
-- Name: conversations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.conversations_id_seq OWNED BY public.conversations.id;
--
-- Name: countries_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.countries_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.countries_id_seq OWNER TO neondb_owner;
--
-- Name: countries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.countries_id_seq OWNED BY public.countries.id;
--
-- Name: data_models; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.data_models (
id integer NOT NULL,
name character varying(100) NOT NULL,
description text,
model_type character varying(50) NOT NULL,
parameters jsonb DEFAULT '{}'::jsonb,
training_data jsonb DEFAULT '{}'::jsonb,
accuracy numeric(5,4),
precision_score numeric(5,4),
recall_score numeric(5,4),
f1_score numeric(5,4),
status character varying(20) DEFAULT 'draft'::character varying,
version character varying(20) DEFAULT '1.0.0'::character varying,
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now(),
trained_at timestamp with time zone
);
ALTER TABLE public.data_models OWNER TO neondb_owner;
--
-- Name: TABLE data_models; Type: COMMENT; Schema: public; Owner: neondb_owner
--
COMMENT ON TABLE public.data_models IS 'Mod├¿les de machine learning entra├«n├®s sur les donn├®es';
--
-- Name: data_models_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.data_models_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.data_models_id_seq OWNER TO neondb_owner;
--
-- Name: data_models_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.data_models_id_seq OWNED BY public.data_models.id;
--
-- Name: insights; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.insights (
id integer NOT NULL,
title character varying(255) NOT NULL,
description text,
insight_type character varying(50) NOT NULL,
data jsonb NOT NULL,
visualization_config jsonb DEFAULT '{}'::jsonb,
source_tables text[],
filters_applied jsonb DEFAULT '{}'::jsonb,
confidence_level numeric(3,2),
target_audience character varying(50) DEFAULT 'all'::character varying,
is_public boolean DEFAULT false,
created_at timestamp with time zone DEFAULT now(),
expires_at timestamp with time zone
);
ALTER TABLE public.insights OWNER TO neondb_owner;
--
-- Name: TABLE insights; Type: COMMENT; Schema: public; Owner: neondb_owner
--
COMMENT ON TABLE public.insights IS 'Insights g├®n├®r├®s par l''IA ├á partir des donn├®es collect├®es';
--
-- Name: insights_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.insights_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.insights_id_seq OWNER TO neondb_owner;
--
-- Name: insights_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.insights_id_seq OWNED BY public.insights.id;
--
-- Name: media; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.media (
id integer NOT NULL,
activity_id integer,
user_id integer,
file_url text NOT NULL,
file_type character varying(50) NOT NULL,
mime_type character varying(100),
file_size integer,
title character varying(255),
description text,
alt_text character varying(255),
width integer,
height integer,
duration integer,
category character varying(50) DEFAULT 'general'::character varying,
is_primary boolean DEFAULT false,
is_public boolean DEFAULT true,
is_approved boolean DEFAULT true,
moderation_notes text,
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.media OWNER TO neondb_owner;
--
-- Name: media_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.media_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.media_id_seq OWNER TO neondb_owner;
--
-- Name: media_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: neondb_owner
--
ALTER SEQUENCE public.media_id_seq OWNED BY public.media.id;
--
-- Name: messages; Type: TABLE; Schema: public; Owner: neondb_owner
--
CREATE TABLE public.messages (
id integer NOT NULL,
conversation_id integer,
sender character varying(20) NOT NULL,
content text NOT NULL,
message_type character varying(20) DEFAULT 'text'::character varying,
intent character varying(50),
entities jsonb DEFAULT '{}'::jsonb,
confidence_score numeric(3,2),
processing_time_ms integer,
referenced_activities integer[],
referenced_categories integer[],
created_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.messages OWNER TO neondb_owner;
--
-- Name: messages_id_seq; Type: SEQUENCE; Schema: public; Owner: neondb_owner
--
CREATE SEQUENCE public.messages_id_seq
AS integer