advanced patterns with Room Database Migrations in Android when Adding New Entity
I tried several approaches but none seem to work. I've been banging my head against this for hours. I tried several approaches but none seem to work. I'm working with an scenario when trying to add a new entity to my existing Room database. I have a `User` entity and I've recently added a `Profile` entity with a one-to-one relationship to `User`. However, during the migration from version 1 to version 2, I get the following behavior: `SQLiteException: table Profile has no column named userId`. I have defined the migration in my database class like this: ```kotlin val MIGRATION_1_2 = object : Migration(1, 2) { override fun migrate(database: SupportSQLiteDatabase) { database.execSQL("CREATE TABLE Profile (id INTEGER PRIMARY KEY NOT NULL, userId INTEGER NOT NULL, bio TEXT)") database.execSQL("ALTER TABLE User ADD COLUMN age INTEGER") } } ``` When I run the app and try to access the `Profile` table, I get this behavior indicating that the `userId` column does not exist. I’ve checked that I am using the correct database version in my `Room.databaseBuilder` call: ```kotlin val db = Room.databaseBuilder(appContext, AppDatabase::class.java, "my_database") .addMigrations(MIGRATION_1_2) .build() ``` I also tried explicitly setting the `userId` column as a foreign key, but it seems to have no effect, and the behavior continues. I’ve verified that the `Profile` class is annotated correctly with `@Entity` and I’ve added the appropriate DAO methods for it as well. Is there something I am missing in the migration process? Any input would be appreciated! This is part of a larger service I'm building. What am I doing wrong? My development environment is Windows. Any help would be greatly appreciated!