d3e00c106e359ffb41d528fb4337ce02ee4400a7
[koha.git] / installer / data / mysql / atomicupdate / bug_15084-add_fk_for_currency.sql
1 -- Add the new currency.archived column
2 alter table currency add column archived tinyint(1) default 0;
3 -- Set currency=NULL if empty (just in case)
4 update aqorders set currency=NULL where currency="";
5 -- Insert the missing currency and mark them as archived before adding the FK
6 insert into currency(currency, archived) select distinct currency, 1 from aqorders where currency not in (select currency from currency);
7 -- And finally add the FK
8 alter table aqorders add foreign key (currency) references currency(currency) on delete set null on update set null;