Move state storage to Postgres
This commit is contained in:
parent
b4693f5609
commit
c3d2bf424e
18 changed files with 1667 additions and 470 deletions
|
|
@ -9,7 +9,7 @@ create table if not exists channel_policies (
|
|||
guild_id text not null,
|
||||
channel_id text not null,
|
||||
indexing_enabled boolean not null default false,
|
||||
provider_allowlist text[] not null default '{}',
|
||||
provider_allowlist text[] not null default '{}'::text[],
|
||||
primary key (guild_id, channel_id)
|
||||
);
|
||||
|
||||
|
|
@ -21,31 +21,39 @@ create table if not exists provider_configs (
|
|||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create table if not exists style_packs (
|
||||
name text primary key,
|
||||
file_path text not null,
|
||||
enabled boolean not null default true,
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create table if not exists state_migrations (
|
||||
name text primary key,
|
||||
applied_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create table if not exists jobs (
|
||||
id uuid primary key,
|
||||
request_message_id text,
|
||||
command_name text not null,
|
||||
state text not null,
|
||||
provider_name text not null,
|
||||
requester_discord_id text not null,
|
||||
guild_id text,
|
||||
channel_id text not null,
|
||||
prompt text not null,
|
||||
context_json jsonb not null,
|
||||
summary text,
|
||||
final_response text,
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now()
|
||||
output_channel_id text not null,
|
||||
created_at timestamptz not null,
|
||||
updated_at timestamptz not null,
|
||||
job_json jsonb not null
|
||||
);
|
||||
|
||||
create table if not exists job_approvals (
|
||||
id bigserial primary key,
|
||||
job_id uuid not null references jobs(id) on delete cascade,
|
||||
stage text not null,
|
||||
status text not null,
|
||||
actor_discord_id text not null,
|
||||
reason text,
|
||||
created_at timestamptz not null default now()
|
||||
);
|
||||
create index if not exists jobs_state_created_idx
|
||||
on jobs (state, created_at);
|
||||
|
||||
create unique index if not exists jobs_request_dedupe_idx
|
||||
on jobs (request_message_id, command_name, provider_name, output_channel_id)
|
||||
where request_message_id is not null;
|
||||
|
||||
create table if not exists provider_runs (
|
||||
id bigserial primary key,
|
||||
|
|
@ -67,36 +75,36 @@ create table if not exists tool_invocations (
|
|||
);
|
||||
|
||||
create table if not exists audit_events (
|
||||
id bigserial primary key,
|
||||
id uuid primary key,
|
||||
job_id uuid references jobs(id) on delete set null,
|
||||
actor_discord_id text,
|
||||
provider_name text,
|
||||
event_type text not null,
|
||||
event_json jsonb not null,
|
||||
created_at timestamptz not null default now()
|
||||
event_timestamp timestamptz not null default now(),
|
||||
event_json jsonb not null
|
||||
);
|
||||
|
||||
create table if not exists message_archives (
|
||||
message_id text primary key,
|
||||
create index if not exists audit_events_job_timestamp_idx
|
||||
on audit_events (job_id, event_timestamp desc);
|
||||
|
||||
create table if not exists interaction_memory_events (
|
||||
id text primary key,
|
||||
actor_id text not null,
|
||||
actor_name text not null,
|
||||
source_kind text not null,
|
||||
guild_id text,
|
||||
channel_id text not null,
|
||||
author_discord_id text not null,
|
||||
content text not null,
|
||||
metadata_json jsonb not null default '{}'::jsonb,
|
||||
created_at timestamptz not null
|
||||
channel_name text,
|
||||
command_name text,
|
||||
prompt text not null,
|
||||
excerpt text not null,
|
||||
summary text not null,
|
||||
sentiment text not null,
|
||||
score integer not null,
|
||||
tags text[] not null default '{}'::text[],
|
||||
event_timestamp timestamptz not null,
|
||||
event_json jsonb not null
|
||||
);
|
||||
|
||||
create table if not exists embedding_chunks (
|
||||
chunk_id text primary key,
|
||||
message_id text not null references message_archives(message_id) on delete cascade,
|
||||
text_content text not null,
|
||||
metadata_json jsonb not null default '{}'::jsonb,
|
||||
embedding vector(1536)
|
||||
);
|
||||
|
||||
create table if not exists style_packs (
|
||||
name text primary key,
|
||||
file_path text not null,
|
||||
enabled boolean not null default true,
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
create index if not exists interaction_memory_events_actor_timestamp_idx
|
||||
on interaction_memory_events (actor_id, event_timestamp desc);
|
||||
|
|
|
|||
Loading…
Reference in a new issue