-
Notifications
You must be signed in to change notification settings - Fork 3
Migrations development
This page collects a bunch of ideas I've been going over for how to support migrations, particularly where there is a type hierarchy.
Let A
, B(A)
, C(B)
, D(A)
be classes where brackets indicate inheriting from.
Here is a list of some migration types that the system should support:
-
B(A)
becomesB
with no parent and no members as copied over.
This is relatively easy as even if there are unnecessary members in the saved state, B
should be able to load old versions by just ignoring them.
- Assume
B
andD
contain aname
member that had previous been migrated from being calledperson_name
. This is then unified and moved intoA
such that they now both inherit it.
We cannot perform this migration on A
as it should not know about the existence of B
or D
, so A
would just set the corresponding entry in the saved state to None
. Migrations can be added to B
and D
to set the name field to the name
they store however, this is fragile as a new version of A
may appear containing a different label (not name
) or even get rid of it entirely. If all migrations are applied to A
first then the migrations on B
and D
would no longer work.
-
B(A)
becomesB
by copying all members and methods fromA
.
If we can copy over the member definitions such that they point to the same state variable in the record then this will continue to work without any migration
- Migrations where a name is shadowed e.g.
A
containsname
as well asB
. This works fine, untilA
is migrated to removename
(or rename it to something else) which will causeB
to stop working.
There is an argument to be made that the saved state variables of a class should be private and therefore subclasses cannot make any use of knowledge about their existence.