#7 Decide migration implementation approach

Отворени
отворен преди 2 седмици от kestrel · 0 коментара

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.
Впишете се за да се присъедините към разговора.
Няма етикет
Няма етап
Няма изпълнител
1 участника
Зареждане...
Отказ
Запис
Все още няма съдържание.