#7 Decide migration implementation approach

Ouvert
Créé il y a 2 semaines par kestrel · 0 commentaires

Broadly speaking, there are two paths forwards for implementing migrations.

Migration approach 1: Column-based

In this approach, a migration consists of a mapper that provides new values for changed entities on a per-entity basis, for each column; possibly this is then followed up with an arbitrary pass to perform more complicated fixups.

Migration approach 2: Type wrapper-based migration

In this approach, a migration consists of a mapper that converts entities of the old schema to entities of the new schema.

Implementation details vary but would probably look something like:

trait NewWrapper<O: Entity, N: Entity> {
    fn map(&mut self, old: O) -> Result<Option<N>>;
}

Other issues

Specifying new Entity types involves recreating every Schema type on the path from the root to the leaf, which could be very obnoxious for some schemata.

Broadly speaking, there are two paths forwards for implementing migrations. #### Migration approach 1: Column-based In this approach, a migration consists of a mapper that provides new values for changed entities on a per-entity basis, for each column; possibly this is then followed up with an arbitrary pass to perform more complicated fixups. #### Migration approach 2: Type wrapper-based migration In this approach, a migration consists of a mapper that converts entities of the old schema to entities of the new schema. Implementation details vary but would probably look something like: ```rust trait NewWrapper<O: Entity, N: Entity> { fn map(&mut self, old: O) -> Result<Option<N>>; } ``` #### Other issues Specifying new Entity types involves recreating every `Schema` type on the path from the root to the leaf, which could be very obnoxious for some schemata.
Connectez-vous pour rejoindre cette conversation.
Pas d'étiquette
Aucun jalon
Pas d'assignataire
1 Participants
Chargement…
Annuler
Enregistrer
Il n'existe pas encore de contenu.