Files
accounted/supabase/migrations/20260514125831_bank_connection_initial_sync_metadata.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

20 lines
918 B
SQL

-- Track initial-sync metadata per bank connection.
--
-- Decouples "have we ever done a backfill" (initial_sync_completed_at) from
-- "when did we last incrementally sync" (last_synced_at). The cron's first-sync
-- 90-day backfill path is gated on initial_sync_completed_at IS NULL, so the
-- "Sync now" button setting last_synced_at no longer permanently loses the
-- backfill window.
--
-- The returned-date columns power the UI's "we requested X but got Y" disclosure
-- when an ASPSP truncates history below the requested window.
ALTER TABLE public.bank_connections
ADD COLUMN IF NOT EXISTS initial_sync_completed_at timestamptz,
ADD COLUMN IF NOT EXISTS initial_sync_requested_from date,
ADD COLUMN IF NOT EXISTS initial_sync_returned_min_date date,
ADD COLUMN IF NOT EXISTS initial_sync_returned_max_date date,
ADD COLUMN IF NOT EXISTS initial_sync_lookback_days int;
NOTIFY pgrst, 'reload schema';