SafeSlingerProject / SafeSlinger-iOS

Source code for iOS platform client SafeSlinger
MIT License
6 stars 2 forks source link

database upgrade fails #83

Closed mwfarb closed 9 years ago

mwfarb commented 9 years ago

New database schema from new column in issue #4 fails to upgrade database for existing users from 1.8.1 (https://github.com/SafeSlingerProject/SafeSlinger-iOS/commit/92f96e5ab6a0d60b4d5bfd4a12363fce8681617a) to 1.82 (https://github.com/SafeSlingerProject/SafeSlinger-iOS/commit/f86708e4a13dc4fdbfe126e5854644146e6c987a) resulting in inability to read and write entries in messages table and the list of threads is now empty (0 Threads) when messages exist in the database. This must be fixed before releasing 1.8.2.

Log: [E]: ERROR: Problem with prepare statement: SELECT receipt, cTime, count(msgid), count(unread), (CASE WHEN receipt IN (SELECT CAST(keyid AS TEXT) FROM (SELECT , max(bdate) FROM (SELECT , max(bdate) FROM tokenstore GROUP BY pid, dev) GROUP BY ptoken, dev ORDER BY pid COLLATE NOCASE DESC)) THEN 1 ELSE 0 END) as active FROM msgtable GROUP BY receipt order by cTime desc; Succeeded! Received 4 bytes of data Return SerV: 1060000 Registration Code: -1983363567 Registration Response: 2x.png [E]: Error while creating statement. 'no such column: unread' [E]: Error while updating data. 'no such column: unread' Succeeded! Received 56 bytes of data Return SerV: 1060000 Send Message Code: 1 Send Message Response: Success: id=0:1433436792423007%ffbd3e92f9fd7ecd [E]: Error while creating statement. 'table msgtable has no column named unread' [E]: ERROR: Error while inserting data. 'table msgtable has no column named unread' [E]: ERROR: Problem with prepare statement: SELECT receipt, cTime, count(msgid), count(unread), (CASE WHEN receipt IN (SELECT CAST(keyid AS TEXT) FROM (SELECT , max(bdate) FROM (SELECT , max(bdate) FROM tokenstore GROUP BY pid, dev) GROUP BY ptoken, dev ORDER BY pid COLLATE NOCASE DESC)) THEN 1 ELSE 0 END) as active FROM msgtable GROUP BY receipt order by cTime desc;

tenmalin commented 9 years ago

To @mwfarb, I believe the branch has been updated even earlier than 92f96e5. The correct one to check might be df7d509.

tenmalin commented 9 years ago

Did you enable beta flag when you upgrade your system?

mwfarb commented 9 years ago

I did a test between df7d509 (Feb 25) upgrade to f86708e (May 31, 1.8.2) as you suggest, which succeeded. However, 1.8.1 was released Feb 2 to iTunes tagged with 109ffaf4be4b3738130594447cdcdfa6cac459c6 (Feb 1, 1.8.1), and I should test between 109ffaf4be4b3738130594447cdcdfa6cac459c6 upgrade to f86708e to be sure.

Hopefully the iOS Member Center will be back up soon after they release whatever they are announcing so I can re-provision my device with the new certificate.

mwfarb commented 9 years ago

I have to apologize. So it seems I can only reproduce this on my test devices only. I've followed the likely path for an old user to upgrade as close as possible and I can honestly not reproduce it. The upgrade issue must have been some issue between commits on my test devices that production users would not encounter.

mwfarb commented 9 years ago

@tenmalin I've resubmitted the same binary for review. My apologies for holding this release up an additional week.

brnunes commented 9 years ago

I'm glad it's working for release versions. The unread column is created if the database's user_version is zero, which should be true for every release version before 1.8.2. In 1.8.2, we set user_version to CURRENT_DATABASE_VERSION, which is 1.