MigrationEntityCE
annotation is used with an entity class to automatically generate a migration when the database schema changes. This allows seamless schema evolution without requiring manual migration definitions.
migrationVersion: Int
Specifies the migration version associated with the entity's table. When the entity structure is modified (e.g., adding or removing fields), this version number ensures that the corresponding migration is generated automatically.
@MigrationEntityCE(migrationVersion = 4)
@Entity
data class User(
@PrimaryKey val id: Int,
val name: String,
val email: String
)
In this example, the User
entity is marked with MigrationEntityCE
, indicating that it belongs to migration version 4. If the structure of User
changes in future versions, the system will automatically generate the necessary migration.
✅ Eliminates the need for manual migration definitions.
✅ Ensures database schema updates are tracked and applied correctly.
✅ Simplifies the migration process while maintaining data integrity.
By using MigrationEntityCE
, developers can focus on defining their entity structures without worrying about handling migrations manually.