chiark / gitweb /
Instructions for deleting black dye
[ypp-sc-tools.db-test.git] / yarrg / devel-notes
1
2 removing an obsolete commodity:
3
4   select * from (select * from sell union select * from buy) left outer join commods using (commodid) where commods.commodname = 'Black dye' limit 10;
5
6 if that produces no output then:
7
8   begin;
9   delete from commods where commodname like 'Black dye';
10   select * from (select * from sell union select * from buy) left outer join commods using (commodid) where commods.commodname is null limit 10;
11
12 and if that produces no output then:
13   commit;
14 otherwise
15   rollback;
16
17 =======================================
18
19 ceb's example route:
20   alpha,byrne,papaya,turtle,jorvik,luthien
21
22 example mixed arbitrage/trade
23   xi,heph
24
25 ========================================
26
27 To remedy bug fixed in 01c14767c024ac56686dbbfcd88d9f3a0b4b1574,
28 did this:
29
30 sqlite> begin;
31 sqlite> insert or ignore into stalls select null, buy.islandid, stalls.stallname from buy, stalls using (stallid);
32 sqlite> insert or ignore into stalls select null, sell.islandid, stalls.stallname from sell, stalls using (stallid);
33 sqlite> update buy set stallid = (select stallid from stalls where stalls.islandid == buy.islandid and stalls.stallname == (select stallname from stalls as bad where buy.stallid == bad.stallid));
34 sqlite> update sell set stallid = (select stallid from stalls where stalls.islandid == sell.islandid and stalls.stallname == (select stallname from stalls as bad where sell.stallid == bad.stallid));
35 sqlite> commit;
36
37 And to check that it worked:
38
39 sqlite> select * from buy offers, stalls using (stallid) where offers.islandid != stalls.islandid group by offers.islandid;
40 sqlite> select * from sell offers, stalls using (stallid) where offers.islandid != stalls.islandid group by offers.islandid;
41 sqlite>