ahmetb / orman

lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)
Other
249 stars 47 forks source link

android.database.sqlite.SQLiteException: Can't downgrade database from version 35 to 33 #42

Closed hippiefahrzeug closed 12 years ago

hippiefahrzeug commented 12 years ago

In order to upgrade my schema I've created my own SQLiteOpenHelper which does the upgrades at startup. In my last update, something bad happened: Users are reporting this error...

Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 35 to 33 at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:307) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:168) at org.orman.dbms.sqliteandroid.SQLiteAndroid.(SQLiteAndroid.java:39) [...]

And indeed, my db version went from 33 to 34. I saw in the orman code the following line:


public class SQLiteAndroid extends SQLiteOpenHelper implements Database { private static final int SQLITE_VERSION = 33; //TODO read from somewhere else ASAP


... and I'm suspecting that this could be causing the problem.

Right now I'm a bit at a loss here, do you see a possibility for a quick fix?

ahmetb commented 12 years ago

Ooops that's my bad. Can you please checkout the code, change the line that inludes 33 and run the command rake in your root? (It will require rake and therefore ruby installed, but it is the way to build our jar right now.) Let me know if you have difficulties.

hippiefahrzeug commented 12 years ago

thank for your quick reply. You're right that will be the fastest way to fix my problem, I will do that. It would be good if you could add a constructor with the version number to SQLiteAndroid.

Cheers, and thanks for orman. Alvi

On Fri, Jan 20, 2012 at 3:00 PM, ahmet alp balkan reply@reply.github.com wrote:

Ooops that's my bad. Can you please checkout the code, change the line that inludes 33 and run the command rake in your root? (It will require rake and therefore ruby installed, but it is the way to build our jar right now.) Let me know if you have difficulties.


Reply to this email directly or view it on GitHub: https://github.com/ahmetalpbalkan/orman/issues/42#issuecomment-3583823

ahmetb commented 12 years ago

That's a good idea. The reason it is coded that way is because I thought it was about "version of SQLite" rather than the version of the app db. Totally a misconception, sorry about that. Hope you have fixed it for yourself, I'll roll out a fix soon when I have time.

Thanks for reporting the bug.

hippiefahrzeug commented 12 years ago

It's fine for me now, I added the constructor and built the project without any problems.

ahmetb commented 12 years ago

Great, feel free to submit a pull request anytime.

Dodd78 commented 12 years ago

may this will be of use to you http://www.enterra-inc.com/techzone/handling_sql_issues/