2

I have used a model inside a model in my app's Room Database. It is like this:

I have a PackageModel

@Entity
public class PackageModel {

@PrimaryKey (autoGenerate = false)
@NonNull
String package_id;

String location mobil,isChecked;

And another model:

@Entity
public class DeliveryJsonModel {

@PrimaryKey @NonNull
String deliveryJsonid;

@Embedded
PackageModel packageModel;

String ktr_datotid, ktrpkt_type,tg_aarsak_kode, aarsak_nr, bruker, sig_fil_ref, id_type;
boolean skade, isPackageScanned, isNotFound;

In this second model, I am using @embedded tag to use PackagModel The Problem started when i added a column deleted in my PackageModel. Since I am using PackageModel in my second model, it is expecting the deleted column there also.

So I wrote the igration for that as:

database.execSQL("ALTER TABLE DeliveryJsonModel ADD COLUMN deleted INTEGER NOT NULL DEFAULT 0");

But my application is throwing a Room error saying that

Room can not handle the migration.

Expected: TableInfo{name='DeliveryJsonModel', columns={deleted=Column{name='deleted', type='INTEGER', notNull=false, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}

Found: TableInfo{name='DeliveryJsonModel', columns={deleted=Column{name='deleted', type='INTEGER', notNull=true, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}

As you can see the deleted value htat is found isfalse, I don't understand why is this happening, I have set the default value to 0 in my migrations.

Can anyone help me?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
The Bat
  • 1,085
  • 1
  • 13
  • 31

0 Answers0