Files
accounted/supabase/migrations/20260712140100_articles_add_currency.sql
T
2026-07-16 16:00:05 +02:00

15 lines
692 B
SQL

-- Articles: optional default currency for the article's price.
--
-- Pre-fills the invoice currency when the article is added to a line (the
-- invoice still carries a single currency; the article supplies the default).
-- 'SEK' = the existing behaviour. Master data only, never posted; the frozen
-- invoice line keeps its own currency, so editing this never moves a voucher.
--
-- Validity is enforced by a FK to public.currencies, NOT a literal CHECK list,
-- so the supported set lives in one place (the currencies table).
ALTER TABLE public.articles
ADD COLUMN IF NOT EXISTS currency text NOT NULL DEFAULT 'SEK'
REFERENCES public.currencies(code);
NOTIFY pgrst, 'reload schema';