"Cannot add a NOT NULL column with default value NULL" with Requery after automatic DB migration
I found a solution of this.
database.execSQL("ALTER TABLE table_name ADD COLUMN colum_name INTEGER DEFAULT 1 not null");
add the command : "DEFAUT value" after data type will solve your problem.
There are two options, first one is probably to be preferred - in the second one, you need to handle possible nullpointers in the code:
option 1
@Entity
abstract class AbstractFooEntity {
...
@Column(value = "0")
int newField;
}
option 2
@Entity
abstract class AbstractFooEntity {
...
Integer newField;
}