Files
accounted/supabase/migrations/20260423140500_processing_history_ai_streams.sql
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

42 lines
1.3 KiB
SQL

-- Extend processing_history to cover the AI agent streams.
--
-- 1) Add 'AIProposal' and 'AIRequest' to the aggregate_type CHECK constraint.
-- 2) Register the new event types in processing_event_types:
-- AIProposalGenerated, AIProposalAccepted, AIProposalRejected,
-- AIProposalSkipped, AIProposalInvalidated, AIRequestCreated,
-- AIRequestResolved.
--
-- Events are written by the orchestrator (lib/ai/orchestrator.ts) and the
-- proposal API routes, using the same correlation_id that was threaded
-- through the document from ingest onward.
ALTER TABLE public.processing_history
DROP CONSTRAINT IF EXISTS processing_history_aggregate_type_check;
ALTER TABLE public.processing_history
ADD CONSTRAINT processing_history_aggregate_type_check
CHECK (aggregate_type IN (
'Document',
'BankTransaction',
'MatchProposal',
'Verifikation',
'CounterpartyTemplate',
'Period',
'Migration',
'System',
'AIProposal',
'AIRequest'
));
INSERT INTO public.processing_event_types (event_type) VALUES
('AIProposalGenerated'),
('AIProposalAccepted'),
('AIProposalRejected'),
('AIProposalSkipped'),
('AIProposalInvalidated'),
('AIRequestCreated'),
('AIRequestResolved')
ON CONFLICT (event_type) DO NOTHING;
NOTIFY pgrst, 'reload schema';