Skip to content

Commit ccf8ce2

Browse files
authored
db: add incident_status_cache table (supabase#43002)
Database migration — adds a new table. ## What is the current behavior? There is no table to cache AI-derived incident metadata. ## What is the new behavior? Adds an `incident_status_cache` table for caching AI-derived incident metadata.
1 parent f563615 commit ccf8ce2

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
create table if not exists public.incident_status_cache (
2+
id bigint primary key generated always as identity,
3+
incident_id text unique not null,
4+
shortlink text unique not null,
5+
updated_at timestamptz not null default now(),
6+
affects_project_creation boolean not null default false,
7+
affected_regions text[]
8+
);
9+
10+
alter table public.incident_status_cache
11+
enable row level security;
12+
13+
revoke all on public.incident_status_cache from anon;
14+
revoke all on public.incident_status_cache from authenticated;
15+
16+
create index if not exists idx_incident_status_cache_incident_id
17+
on public.incident_status_cache (incident_id);
18+
19+
create index if not exists idx_incident_status_cache_shortlink
20+
on public.incident_status_cache (shortlink);
21+
22+
create or replace function public.set_updated_at()
23+
returns trigger
24+
language plpgsql
25+
as $$
26+
begin
27+
new.updated_at = now();
28+
return new;
29+
end;
30+
$$;
31+
32+
create trigger set_incident_status_cache_updated_at
33+
before update on public.incident_status_cache
34+
for each row
35+
execute function public.set_updated_at();

0 commit comments

Comments
 (0)