#7 Decide migration implementation approach

Mở
%! (template.HTML=2 tuần trước cách đây)đang mở bởi kestrel · 0 ý kiến

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.
Đăng nhập để tham gia bình luận.
Không có nhãn
Không có Milestone
Không có người được phân công
1 tham gia
Đang tải...
Hủy bỏ
Lưu
Ở đây vẫn chưa có nội dung nào.