Files
crank/crates/crank-registry/src/migrations/approval_side_effects_v10.sql
T

38 lines
1.1 KiB
SQL

alter table approval_requests
add column if not exists request_id text null;
alter table approval_requests
add column if not exists trace_id text null;
alter table approval_requests
add constraint approval_requests_request_id_check check (
request_id is null
or (
octet_length(request_id) between 1 and 128
and request_id !~ '[[:cntrl:],;]'
)
) not valid;
alter table approval_requests
add constraint approval_requests_trace_id_check check (
trace_id is null
or (
trace_id ~ '^[0-9a-f]{32}$'
and trace_id <> '00000000000000000000000000000000'
)
) not valid;
create unique index if not exists approval_requests_pending_scope_fingerprint_idx
on approval_requests(
workspace_id,
agent_id,
operation_id,
operation_version,
request_fingerprint
)
where status = 'pending' and request_fingerprint is not null;
create index if not exists approval_requests_workspace_request_trace_idx
on approval_requests(workspace_id, request_id, trace_id)
where request_id is not null or trace_id is not null;