App crashes if add new column in new version of app
See original GitHub issueDBFlow Version: 4.1.1 Issue Kind (Bug, Question, Feature): Bug
I add new column to table cause crash
Description: I added some tables in my app with DBFlow in previous app version. Now I want to add new column to one of tables in new version of app. When I update and run the app, the app crashes. But I remove previous version and install new version, any things are ok. logcat report:
FATAL EXCEPTION: main Process: com.consoleco.console, PID: 12896 android.database.sqlite.SQLiteException: table Message has no column named link (code 1): , while compiling: INSERT OR REPLACE INTO
Message(
messageId,
date,
sender,
messageTitle,
messageBody,
link) VALUES (?,?,?,?,?,?) at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:893) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:504) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58) at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31) at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1017) at com.raizlabs.android.dbflow.structure.database.AndroidDatabase.compileStatement(AndroidDatabase.java:56) at com.raizlabs.android.dbflow.structure.ModelAdapter.getInsertStatement(ModelAdapter.java:119) at com.raizlabs.android.dbflow.structure.ModelAdapter.getInsertStatement(ModelAdapter.java:58) at com.raizlabs.android.dbflow.sql.saveable.ModelSaver.save(ModelSaver.java:29) at com.raizlabs.android.dbflow.structure.ModelAdapter.save(ModelAdapter.java:185) at com.raizlabs.android.dbflow.structure.BaseModel.save(BaseModel.java:62) at com.consoleco.console.object.Message.<init>(Message.java:63) at com.consoleco.console.page.SupportPage$2$1.onResponse(SupportPage.java:123) at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)at android.os.Handler.handleCallback(Handler.java:808) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:193)at android.app.ActivityThread.main(ActivityThread.java:5345) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) at dalvik.system.NativeStart.main(Native Method)
I tested these: I increased integer of version = MyDatabase.VERSION I increased app versionCode I disabled Instant Run
But the problem not solved.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top GitHub Comments
Did you create a migration for the incremented database version? This would be the migration if your database version was bumped up to version 6 and your new column was called “new_column”.
Below is my migration class @Migration(version = 7, database = XYZDatabase.class) public class Migration6 extends BaseMigration {
}
but it still table User has no column named username (code 1): , while compiling: INSERT INTO
User
(userId
,name
,phone
,thumb
,placeholder
,username
) VALUES (?,?,?,?,?,?) crash.