Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migrations for geary entities #10

Open
Derongan opened this issue Jan 26, 2021 · 2 comments
Open

Add migrations for geary entities #10

Derongan opened this issue Jan 26, 2021 · 2 comments
Labels
type:enhancement New feature or request

Comments

@Derongan
Copy link
Member

In geary-1.0 we had the concept of migrating entities when the definition updated. This was put in place to prevent existing items breaking on an upgrade.

(see https://github.com/MineInAbyss/geary-1.0/blob/ebcfaa4deed2f28c523db9384b16375282eac344/src/main/java/com/mineinabyss/geary/ecs/entity/migration/GearyEntityMigration.java#L11)

Something to support the same use case is necessary for Geary.

Basic outline:

  1. Attach a (non static, persistent) component to every entity containing a simple version number for each component. (if version #0 do not serialize to keep component from bloating)
  2. Component providers provide a migration specific to component whenever a component needs to change. Migration handles updating from serialized form (because the class definition has probably changed). This might be a bit tricky.
  3. On loading an entity for the first time on a server restart (be it from PDC, or what have you) compare the version number for each component with the version number of the latest migration.
  4. On mismatch apply all registered migrations in order starting from the first one with a higher version #.
@Derongan Derongan added type:enhancement New feature or request difficulty:hard labels Jan 26, 2021
@0ffz
Copy link
Member

0ffz commented Jan 26, 2021

Just looking around, I found

Overall mapneat seems pretty close to everything we'd want, and since it's a DSL we could likely add our own operations if needed in the future.

@0ffz
Copy link
Member

0ffz commented Jan 26, 2021

Since a lot of these libraries are focused on JSON, the full migration process from PDC would require us to convert from CBOR to JSON, migrate, then use ktx.serialization on that json file (we dont need to convert it back to CBOR since ktx.serialization works on multiple formats).

Unfortunately, we dont have access to the old serializer so we can't use ktx.serialization to directly make the CBOR to JSON transformation, we need something in between. We need to find a library to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants