diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index 23a8b39..9e43fae 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -475,6 +475,11 @@ export type Database = { natural_language_input: string next_run_at: string | null required_mcp_slugs: Json + runtime_last_delivery_error: string | null + runtime_last_error: string | null + runtime_last_status: string | null + runtime_state: string | null + runtime_synced_at: string | null status: string timezone: string updated_at: string @@ -494,6 +499,11 @@ export type Database = { natural_language_input: string next_run_at?: string | null required_mcp_slugs?: Json + runtime_last_delivery_error?: string | null + runtime_last_error?: string | null + runtime_last_status?: string | null + runtime_state?: string | null + runtime_synced_at?: string | null status?: string timezone?: string updated_at?: string @@ -513,6 +523,11 @@ export type Database = { natural_language_input?: string next_run_at?: string | null required_mcp_slugs?: Json + runtime_last_delivery_error?: string | null + runtime_last_error?: string | null + runtime_last_status?: string | null + runtime_state?: string | null + runtime_synced_at?: string | null status?: string timezone?: string updated_at?: string diff --git a/supabase/migrations/20260430235614_5da6a024-f1ea-4e9b-9095-ad70c9e03229.sql b/supabase/migrations/20260430235614_5da6a024-f1ea-4e9b-9095-ad70c9e03229.sql new file mode 100644 index 0000000..e787d2d --- /dev/null +++ b/supabase/migrations/20260430235614_5da6a024-f1ea-4e9b-9095-ad70c9e03229.sql @@ -0,0 +1,20 @@ +-- FASE 5 — Observabilidade do runtime de cronjobs + +ALTER TABLE public.scheduled_jobs + DROP CONSTRAINT IF EXISTS scheduled_jobs_status_check; + +ALTER TABLE public.scheduled_jobs + ADD CONSTRAINT scheduled_jobs_status_check + CHECK (status IN ('active', 'paused', 'auto_paused', 'error', 'archived')); + +ALTER TABLE public.scheduled_jobs + ADD COLUMN IF NOT EXISTS runtime_state text + CHECK (runtime_state IS NULL OR runtime_state IN ('scheduled', 'paused', 'completed', 'error')), + ADD COLUMN IF NOT EXISTS runtime_last_status text + CHECK (runtime_last_status IS NULL OR runtime_last_status IN ('ok', 'error')), + ADD COLUMN IF NOT EXISTS runtime_last_error text, + ADD COLUMN IF NOT EXISTS runtime_last_delivery_error text, + ADD COLUMN IF NOT EXISTS runtime_synced_at timestamptz; + +CREATE INDEX IF NOT EXISTS idx_scheduled_jobs_agent_runtime_synced_at + ON public.scheduled_jobs (agent_instance_id, runtime_synced_at DESC NULLS LAST); \ No newline at end of file