-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.sql
More file actions
2024 lines (1356 loc) · 54.9 KB
/
schema.sql
File metadata and controls
2024 lines (1356 loc) · 54.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
--
\restrict kAaEjsPWLLEcViniWnrQZu7LrzsULDle34hUHzdBk5twSi0Sd3NsjVeLWJhhZoe
-- Dumped from database version 17.9 (Debian 17.9-0+deb13u1)
-- Dumped by pg_dump version 17.9 (Debian 17.9-0+deb13u1)
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: vector; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS vector WITH SCHEMA public;
--
-- Name: EXTENSION vector; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION vector IS 'vector data type and ivfflat and hnsw access methods';
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: actor_visibility_configuration; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.actor_visibility_configuration (
id integer NOT NULL,
actor_id integer NOT NULL,
target_actor_id integer,
created_at timestamp with time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.actor_visibility_configuration OWNER TO postgres;
--
-- Name: actor_visibility_configuration_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.actor_visibility_configuration_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.actor_visibility_configuration_id_seq OWNER TO postgres;
--
-- Name: actor_visibility_configuration_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.actor_visibility_configuration_id_seq OWNED BY public.actor_visibility_configuration.id;
--
-- Name: actors; Type: TABLE; Schema: public; Owner: memory_api
--
CREATE TABLE public.actors (
id integer NOT NULL,
name character varying(50) NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
token_hash character varying(128),
token_salt character varying(64),
password_hash text,
password_salt text,
passphrase_rotated_at timestamp with time zone,
status character varying(20) DEFAULT 'active'::character varying NOT NULL,
last_seen timestamp with time zone,
active_since timestamp with time zone,
expertise text DEFAULT '[]'::text NOT NULL,
CONSTRAINT chk_actors_status CHECK (((status)::text = 'active'::text))
);
ALTER TABLE public.actors OWNER TO memory_api;
--
-- Name: actors_id_seq; Type: SEQUENCE; Schema: public; Owner: memory_api
--
CREATE SEQUENCE public.actors_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.actors_id_seq OWNER TO memory_api;
--
-- Name: actors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: memory_api
--
ALTER SEQUENCE public.actors_id_seq OWNED BY public.actors.id;
--
-- Name: admin_permissions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.admin_permissions (
id integer NOT NULL,
actor_id integer NOT NULL,
resource character varying(50) NOT NULL,
action character varying(50) NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.admin_permissions OWNER TO postgres;
--
-- Name: admin_permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.admin_permissions_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.admin_permissions_id_seq OWNER TO postgres;
--
-- Name: admin_permissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.admin_permissions_id_seq OWNED BY public.admin_permissions.id;
--
-- Name: agent_api_keys; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.agent_api_keys (
id integer NOT NULL,
key_hash character varying(255) NOT NULL,
key_salt character varying(64) NOT NULL,
label character varying(100),
created_at timestamp with time zone DEFAULT now(),
last_used_at timestamp with time zone,
revoked_at timestamp with time zone,
actor_id integer NOT NULL
);
ALTER TABLE public.agent_api_keys OWNER TO postgres;
--
-- Name: agent_api_keys_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.agent_api_keys_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.agent_api_keys_id_seq OWNER TO postgres;
--
-- Name: agent_api_keys_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.agent_api_keys_id_seq OWNED BY public.agent_api_keys.id;
--
-- Name: agent_configuration; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.agent_configuration (
startup_instructions text,
provider character varying(50),
model character varying(100),
virtual boolean DEFAULT false NOT NULL,
personality text,
api_key character varying(512),
configuration text,
cache_prompts boolean DEFAULT false NOT NULL,
learning_enabled boolean DEFAULT true NOT NULL,
max_tokens integer,
temperature numeric,
cost_budget_daily numeric(10,2),
cost_budget_monthly numeric(10,2),
actor_id integer NOT NULL,
CONSTRAINT chk_agent_configuration_provider CHECK (((provider IS NULL) OR ((provider)::text = ANY ((ARRAY['anthropic'::character varying, 'google'::character varying, 'openai'::character varying, 'perplexity'::character varying])::text[]))))
);
ALTER TABLE public.agent_configuration OWNER TO postgres;
--
-- Name: agent_permissions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.agent_permissions (
permission_id integer NOT NULL,
granted_at timestamp with time zone DEFAULT now(),
actor_id integer NOT NULL
);
ALTER TABLE public.agent_permissions OWNER TO postgres;
--
-- Name: agent_status; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW public.agent_status AS
SELECT ac.id AS actor_id,
ac.name AS agent,
CASE
WHEN (agc.virtual = true) THEN 'available'::text
WHEN (ac.last_seen > (now() - '00:15:00'::interval)) THEN 'online'::text
WHEN (ac.last_seen IS NOT NULL) THEN 'offline'::text
ELSE 'unknown'::text
END AS status,
ac.last_seen,
ac.passphrase_rotated_at,
ac.created_at AS registered_at,
ac.expertise,
agc.provider,
agc.model,
agc.virtual,
agc.personality,
agc.cost_budget_daily,
agc.cost_budget_monthly,
CASE
WHEN ((ac.active_since IS NOT NULL) AND (ac.active_since > (now() - '00:30:00'::interval))) THEN ac.active_since
ELSE NULL::timestamp with time zone
END AS active_since,
agc.cache_prompts,
agc.learning_enabled,
agc.max_tokens,
agc.temperature,
agc.configuration
FROM (public.actors ac
JOIN public.agent_configuration agc ON ((agc.actor_id = ac.id)));
ALTER VIEW public.agent_status OWNER TO postgres;
--
-- Name: chat_message_texts; Type: TABLE; Schema: public; Owner: postgres
-- Stores message content once per logical send (MEM-107)
--
CREATE TABLE public.chat_message_texts (
id integer NOT NULL,
message text NOT NULL,
from_actor_id integer NOT NULL,
discussion_id integer,
sent_at timestamp with time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.chat_message_texts OWNER TO postgres;
CREATE SEQUENCE public.chat_message_texts_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.chat_message_texts_id_seq OWNER TO postgres;
ALTER SEQUENCE public.chat_message_texts_id_seq OWNED BY public.chat_message_texts.id;
--
-- Name: chat_messages; Type: TABLE; Schema: public; Owner: postgres
-- Delivery/recipient tracking table (MEM-107)
--
CREATE TABLE public.chat_messages (
id integer NOT NULL,
message_text_id integer NOT NULL,
to_actor_id integer,
acked_at timestamp with time zone,
deleted_at timestamp with time zone
);
ALTER TABLE public.chat_messages OWNER TO postgres;
--
-- Name: chat_messages_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.chat_messages_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.chat_messages_id_seq OWNER TO postgres;
--
-- Name: chat_messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.chat_messages_id_seq OWNED BY public.chat_messages.id;
--
-- Name: memory_chunks; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.memory_chunks (
id integer NOT NULL,
namespace character varying(50) NOT NULL,
source_file character varying(500) NOT NULL,
heading character varying(500),
chunk_text text NOT NULL,
embedding public.vector(1536),
ingested_at timestamp with time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.memory_chunks OWNER TO postgres;
--
-- Name: chunks_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.chunks_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.chunks_id_seq OWNER TO postgres;
--
-- Name: chunks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.chunks_id_seq OWNED BY public.memory_chunks.id;
--
-- Name: config; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.config (
key character varying(100) NOT NULL,
value text NOT NULL,
description text,
updated_at timestamp with time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.config OWNER TO postgres;
--
-- Name: discussion_ballots; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.discussion_ballots (
vote_id integer NOT NULL,
choice integer NOT NULL,
reason text,
cast_at timestamp with time zone DEFAULT now() NOT NULL,
actor_id integer NOT NULL
);
ALTER TABLE public.discussion_ballots OWNER TO postgres;
--
-- Name: discussion_participants; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.discussion_participants (
discussion_id integer NOT NULL,
status character varying(20) DEFAULT 'invited'::character varying NOT NULL,
invited_at timestamp with time zone DEFAULT now() NOT NULL,
joined_at timestamp with time zone,
role character varying(20) DEFAULT 'required'::character varying NOT NULL,
deferred_at timestamp with time zone,
defer_count integer DEFAULT 0,
actor_id integer NOT NULL,
CONSTRAINT chk_discussion_participants_role CHECK (((role)::text = ANY ((ARRAY['required'::character varying, 'optional'::character varying])::text[]))),
CONSTRAINT chk_discussion_participants_status CHECK (((status)::text = ANY ((ARRAY['invited'::character varying, 'joined'::character varying, 'left'::character varying, 'timed_out'::character varying])::text[]))),
CONSTRAINT discussion_participants_status_check CHECK (((status)::text = ANY ((ARRAY['invited'::character varying, 'joined'::character varying, 'left'::character varying, 'timed_out'::character varying, 'deferred'::character varying])::text[])))
);
ALTER TABLE public.discussion_participants OWNER TO postgres;
--
-- Name: discussion_votes; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.discussion_votes (
id integer NOT NULL,
discussion_id integer NOT NULL,
question text NOT NULL,
status character varying(20) DEFAULT 'open'::character varying NOT NULL,
type character varying(20) DEFAULT 'general'::character varying NOT NULL,
threshold character varying(20) DEFAULT 'unanimous'::character varying NOT NULL,
closes_at timestamp with time zone,
created_at timestamp with time zone DEFAULT now() NOT NULL,
closed_at timestamp with time zone,
proposed_by_actor_id integer NOT NULL,
CONSTRAINT chk_discussion_votes_status CHECK (((status)::text = ANY ((ARRAY['open'::character varying, 'closed'::character varying])::text[]))),
CONSTRAINT chk_discussion_votes_threshold CHECK (((threshold)::text = ANY ((ARRAY['unanimous'::character varying, 'majority'::character varying])::text[]))),
CONSTRAINT chk_discussion_votes_type CHECK (((type)::text = ANY ((ARRAY['general'::character varying, 'conclude'::character varying])::text[])))
);
ALTER TABLE public.discussion_votes OWNER TO postgres;
--
-- Name: discussion_votes_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.discussion_votes_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.discussion_votes_id_seq OWNER TO postgres;
--
-- Name: discussion_votes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.discussion_votes_id_seq OWNED BY public.discussion_votes.id;
--
-- Name: discussions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.discussions (
id integer NOT NULL,
topic text NOT NULL,
status character varying(20) DEFAULT 'active'::character varying NOT NULL,
channel character varying(50),
created_at timestamp with time zone DEFAULT now() NOT NULL,
concluded_at timestamp with time zone,
mode character varying(20) DEFAULT 'realtime'::character varying NOT NULL,
context text,
timeout_at timestamp with time zone,
outcome character varying(20),
created_by_actor_id integer NOT NULL,
CONSTRAINT chk_discussions_mode CHECK (((mode)::text = ANY ((ARRAY['realtime'::character varying, 'async'::character varying])::text[]))),
CONSTRAINT chk_discussions_outcome CHECK (((outcome)::text = ANY ((ARRAY['consensus'::character varying, 'deadlock'::character varying, 'partial'::character varying, 'abandoned'::character varying])::text[]))),
CONSTRAINT chk_discussions_status CHECK (((status)::text = ANY ((ARRAY['waiting'::character varying, 'active'::character varying, 'concluded'::character varying, 'cancelled'::character varying, 'timed_out'::character varying])::text[])))
);
ALTER TABLE public.discussions OWNER TO postgres;
--
-- Name: discussions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.discussions_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.discussions_id_seq OWNER TO postgres;
--
-- Name: discussions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.discussions_id_seq OWNED BY public.discussions.id;
--
-- Name: documents; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.documents (
id integer NOT NULL,
namespace character varying(64) NOT NULL,
slug character varying(255) NOT NULL,
title character varying(500),
content text NOT NULL,
created_at timestamp with time zone DEFAULT now(),
updated_at timestamp with time zone DEFAULT now(),
deleted_at timestamp with time zone,
created_by_actor_id integer
);
ALTER TABLE public.documents OWNER TO postgres;
--
-- Name: documents_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.documents_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.documents_id_seq OWNER TO postgres;
--
-- Name: documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.documents_id_seq OWNED BY public.documents.id;
--
-- Name: error_log; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.error_log (
id integer NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
subsystem text NOT NULL,
action text NOT NULL,
context text,
context_id text,
error_message text NOT NULL,
error_detail text,
actor_id integer
);
ALTER TABLE public.error_log OWNER TO postgres;
--
-- Name: error_log_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.error_log_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.error_log_id_seq OWNER TO postgres;
--
-- Name: error_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.error_log_id_seq OWNED BY public.error_log.id;
--
-- Name: mail; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.mail (
id uuid DEFAULT gen_random_uuid() NOT NULL,
subject character varying(500) NOT NULL,
body text NOT NULL,
sent_at timestamp with time zone DEFAULT now() NOT NULL,
acked_at timestamp with time zone,
deleted_at timestamp with time zone,
from_actor_id integer,
to_actor_id integer NOT NULL
);
ALTER TABLE public.mail OWNER TO postgres;
--
-- Name: mcp_sessions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.mcp_sessions (
session_id text NOT NULL,
tools_hash text NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
actor_id integer NOT NULL
);
ALTER TABLE public.mcp_sessions OWNER TO postgres;
--
-- Name: migrations_applied; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.migrations_applied (
migration_id character varying(50) NOT NULL,
applied_at timestamp with time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.migrations_applied OWNER TO postgres;
--
-- Name: namespace_permissions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.namespace_permissions (
id integer NOT NULL,
actor_id integer NOT NULL,
namespace character varying(100) NOT NULL,
can_read boolean DEFAULT false NOT NULL,
can_write boolean DEFAULT false NOT NULL,
can_delete boolean DEFAULT false NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.namespace_permissions OWNER TO postgres;
--
-- Name: namespace_permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.namespace_permissions_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.namespace_permissions_id_seq OWNER TO postgres;
--
-- Name: namespace_permissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.namespace_permissions_id_seq OWNED BY public.namespace_permissions.id;
--
-- Name: permissions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.permissions (
id integer NOT NULL,
name character varying(100) NOT NULL,
created_at timestamp with time zone DEFAULT now()
);
ALTER TABLE public.permissions OWNER TO postgres;
--
-- Name: permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.permissions_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.permissions_id_seq OWNER TO postgres;
--
-- Name: permissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.permissions_id_seq OWNED BY public.permissions.id;
--
-- Name: request_log; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.request_log (
id integer NOT NULL,
"timestamp" timestamp with time zone DEFAULT now() NOT NULL,
method character varying(10) NOT NULL,
path text,
status integer,
duration_ms integer,
ip character varying(45),
request_length integer,
response_length integer,
actor_id integer
);
ALTER TABLE public.request_log OWNER TO postgres;
--
-- Name: request_log_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.request_log_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.request_log_id_seq OWNER TO postgres;
--
-- Name: request_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.request_log_id_seq OWNED BY public.request_log.id;
--
-- Name: sessions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.sessions (
id uuid DEFAULT gen_random_uuid() NOT NULL,
actor_id integer NOT NULL,
token_hash text NOT NULL,
token_salt text NOT NULL,
kind character varying(10) NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
expires_at timestamp with time zone NOT NULL,
subsystem text,
CONSTRAINT sessions_kind_check CHECK (((kind)::text = ANY ((ARRAY['web'::character varying, 'api'::character varying])::text[])))
);
ALTER TABLE public.sessions OWNER TO postgres;
--
-- Name: system_errors; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.system_errors (
id integer NOT NULL,
source text NOT NULL,
error_code text NOT NULL,
context jsonb,
status text DEFAULT 'unhandled'::text NOT NULL,
handler_action text,
resolved_at timestamp with time zone,
reported_at timestamp with time zone DEFAULT now(),
actor_id integer
);
ALTER TABLE public.system_errors OWNER TO postgres;
--
-- Name: system_errors_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.system_errors_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.system_errors_id_seq OWNER TO postgres;
--
-- Name: system_errors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.system_errors_id_seq OWNED BY public.system_errors.id;
--
-- Name: templates; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.templates (
id integer NOT NULL,
name character varying(100) NOT NULL,
description text,
content text NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
kind character varying(50) DEFAULT 'welcome'::character varying NOT NULL,
CONSTRAINT templates_kind_check CHECK (((kind)::text = 'welcome'::text))
);
ALTER TABLE public.templates OWNER TO postgres;
--
-- Name: virtual_agent_usage; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.virtual_agent_usage (
id integer NOT NULL,
provider character varying(50),
model character varying(100),
input_tokens integer DEFAULT 0,
output_tokens integer DEFAULT 0,
cache_write_tokens integer DEFAULT 0,
cache_read_tokens integer DEFAULT 0,
cost numeric(10,6) DEFAULT 0 NOT NULL,
context character varying(50),
created_at timestamp with time zone DEFAULT now(),
actor_id integer NOT NULL
);
ALTER TABLE public.virtual_agent_usage OWNER TO postgres;
--
-- Name: virtual_agent_usage_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.virtual_agent_usage_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.virtual_agent_usage_id_seq OWNER TO postgres;
--
-- Name: virtual_agent_usage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.virtual_agent_usage_id_seq OWNED BY public.virtual_agent_usage.id;
--
-- Name: welcome_templates_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.welcome_templates_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.welcome_templates_id_seq OWNER TO postgres;
--
-- Name: welcome_templates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.welcome_templates_id_seq OWNED BY public.templates.id;
--
-- Name: actor_visibility_configuration id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.actor_visibility_configuration ALTER COLUMN id SET DEFAULT nextval('public.actor_visibility_configuration_id_seq'::regclass);
--
-- Name: actors id; Type: DEFAULT; Schema: public; Owner: memory_api
--
ALTER TABLE ONLY public.actors ALTER COLUMN id SET DEFAULT nextval('public.actors_id_seq'::regclass);
--
-- Name: admin_permissions id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.admin_permissions ALTER COLUMN id SET DEFAULT nextval('public.admin_permissions_id_seq'::regclass);
--
-- Name: agent_api_keys id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.agent_api_keys ALTER COLUMN id SET DEFAULT nextval('public.agent_api_keys_id_seq'::regclass);
--
-- Name: chat_messages id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.chat_message_texts ALTER COLUMN id SET DEFAULT nextval('public.chat_message_texts_id_seq'::regclass);
ALTER TABLE ONLY public.chat_messages ALTER COLUMN id SET DEFAULT nextval('public.chat_messages_id_seq'::regclass);
--
-- Name: discussion_votes id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.discussion_votes ALTER COLUMN id SET DEFAULT nextval('public.discussion_votes_id_seq'::regclass);
--
-- Name: discussions id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.discussions ALTER COLUMN id SET DEFAULT nextval('public.discussions_id_seq'::regclass);
--
-- Name: documents id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.documents ALTER COLUMN id SET DEFAULT nextval('public.documents_id_seq'::regclass);
--
-- Name: error_log id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.error_log ALTER COLUMN id SET DEFAULT nextval('public.error_log_id_seq'::regclass);
--
-- Name: memory_chunks id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.memory_chunks ALTER COLUMN id SET DEFAULT nextval('public.chunks_id_seq'::regclass);
--
-- Name: namespace_permissions id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.namespace_permissions ALTER COLUMN id SET DEFAULT nextval('public.namespace_permissions_id_seq'::regclass);
--
-- Name: permissions id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.permissions ALTER COLUMN id SET DEFAULT nextval('public.permissions_id_seq'::regclass);
--
-- Name: request_log id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.request_log ALTER COLUMN id SET DEFAULT nextval('public.request_log_id_seq'::regclass);
--
-- Name: system_errors id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.system_errors ALTER COLUMN id SET DEFAULT nextval('public.system_errors_id_seq'::regclass);