Handling Room Database Migrations
Learn how to handle database migrations using the Room persistence library.
We must perform database migrations whenever we change the table schemas—that is, modify, add, or delete a field in an existing table or add a new table. The app should gracefully handle all the database upgrades for both new and existing users. If all the upgrade scenarios aren’t handled, it may cause the app to crash or may corrupt users’ data.
Database migrations
Database migrations can either be automatic or manual. In this section, we’ll learn about both kinds of migrations.
To refresh our memories, let’s look at the MyDatabase
class we defined in the “Working with Room Databases” lesson.
Get hands-on with 1400+ tech skills courses.