Line 0
Link Here
|
0 |
- |
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; |