chiark / gitweb /
Some notes regarding database corruption fix
[ypp-sc-tools.db-test.git] / yarrg / devel-notes
diff --git a/yarrg/devel-notes b/yarrg/devel-notes
new file mode 100644 (file)
index 0000000..27335dd
--- /dev/null
@@ -0,0 +1,15 @@
+To remedy bug fixed in 01c14767c024ac56686dbbfcd88d9f3a0b4b1574,
+did this:
+
+sqlite> begin;
+sqlite> insert or ignore into stalls select null, buy.islandid, stalls.stallname from buy, stalls using (stallid);
+sqlite> insert or ignore into stalls select null, sell.islandid, stalls.stallname from sell, stalls using (stallid);
+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));
+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));
+sqlite> commit;
+
+And to check that it worked:
+
+sqlite> select * from buy offers, stalls using (stallid) where offers.islandid != stalls.islandid group by offers.islandid;
+sqlite> select * from sell offers, stalls using (stallid) where offers.islandid != stalls.islandid group by offers.islandid;
+sqlite>