Search code examples
androidsqliterx-javaandroid-roomdatabase-migration

Room does not update exsisting predefined database


I've got a simple table:

CREATE TABLE "Driver" (
"id"    INTEGER NOT NULL,
"firstName" TEXT NOT NULL,
"lastName"  TEXT NOT NULL,
"driverName"    TEXT NOT NULL UNIQUE,
"birthDate" INTEGER,
"drivingLicNum" TEXT,
"drivingLicExpDate" INTEGER,
"issuingAuthority"  TEXT,
"licCategory"   TEXT,
"isActive"  INTEGER NOT NULL DEFAULT 1 CHECK("isActive" IN (0, 1)),
"profilePic"    TEXT,
PRIMARY KEY("id" AUTOINCREMENT)
);

My code for using creating the database:

Room.databaseBuilder(context, VehicleexDatabase.class, "myprefdefdb.db").fallbackToDestructiveMigration()
                .createFromAsset("databases/myprefdefdb.db").build();

The issue was that I HAD a UNIQUE COLUMN for "drivingLicNum", however as I saw it as unneccesary I decided to remove the column from my predefined database, deinstalled the app, and launched the new app with the new predefined database.

However I still receive the issue that there is a UNIQUE CONSTRAINT for the column "drivingLicNum" even tho I removed the UNIQUE statement. Am I missing something?


Solution

  • Found the issue: I've forgot to remove the UNIQUE Index in my Entity class.