Files
accounted/supabase/migrations/20260516140000_depreciation_schedules_updated_at.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
935 B
SQL

-- Adds the missing updated_at column + trigger to depreciation_schedules.
-- The previous migration (20260516120000_assets_and_depreciation) seeded the
-- table without it, which violates the project convention requiring every
-- table to have updated_at managed by update_updated_at_column(). Since rows
-- there only mutate twice (insert, then later when the post handler fills
-- in journal_entry_id + posted_at), updated_at lets audits trace the latest
-- state change without joining against journal_entries.created_at.
ALTER TABLE public.depreciation_schedules
ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ NOT NULL DEFAULT now();
DROP TRIGGER IF EXISTS depreciation_schedules_updated_at
ON public.depreciation_schedules;
CREATE TRIGGER depreciation_schedules_updated_at
BEFORE UPDATE ON public.depreciation_schedules
FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();
NOTIFY pgrst, 'reload schema';