-- P5-6518: add currency to markets

alter table markets
    add column currency text;


alter table markets
    add constraint currency_fkey
    foreign key (currency)
    references "product-currencies" (iso3char) match simple;


update markets set currency = 'SEK' where name = 'SE';
update markets set currency = 'NOK' where name = 'NO';
update markets set currency = 'GBP' where name = 'GB';
update markets set currency = 'DKK' where name = 'DK';
update markets set currency = 'EUR' where name = 'FI';
update markets set currency = 'EUR' where name = 'GLOBAL';
update markets set currency = 'EUR' where name = 'DE';
update markets set currency = 'EUR' where name = 'NL';
update markets set currency = 'EUR' where name = 'AT';
update markets set currency = 'USD' where name = 'US';
update markets set currency = 'EUR' where name = 'ES';
update markets set currency = 'EUR' where name = 'FR';
update markets set currency = 'EUR' where name = 'PL';
update markets set currency = 'EUR' where name = 'IT';


alter table markets
    alter column currency set not null;
