Closed mgohin closed 6 years ago
I'm migrating all my current code to use your lib, could be very nice to add this feat, I guess it's not that complicated.
Using a constant that changes for a name used in Migrations are a very bad idea. If you ever rename that class, your migrations might stop working.
E.g
if (oldVersion == 0) {
// Create Foo
oldVersion++;
}
if (oldVersion == 1) {
// Rename to Bar
oldVersion++;
}
if(oldVersion == 2) {
// Rename to Baz
// If anyone ever upgrades directly from V1 to V3, the step in V2 will break with a generated
// constant name
oldVersion++;
}
For that reason, adding the class name doesn't make a lot of sense, especially since any name for it could potentially clash with a field name.
It's same for fields, when you rename/delete a field you have to update the migration.
For migration we need to use the class name and not the
.class
as explained here : Realm migrationCan you add a field like you do for lists with the
$
to avoid errors when user the class name as a plain string in code ?