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

DataModel migration from 0.1.1 => 2.2.1 characters overwrites fp and extends bonds #81

Closed
blandcr opened this issue Feb 26, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@blandcr
Copy link

blandcr commented Feb 26, 2024

Bug Description:
The bug involves two somewhat related issues:

  1. When running data migration for characters made in 0.1.1 the Fabula Points from the system.fp always overwrite the fabula points stored in system.resources.fp
    • Solving this is a bit tricky since 0.1.1 seems to have a bug where the data template specifies system.resources.fp however the system itself incorrectly? uses system.fp.
  2. When running data migration for characters made in 0.1.1 the Bond migration will append extra entries.
    • This one is pretty easy to see in the code -- Looking at migrateLegacyBonds you can see pretty clearly that bondN properties get pushed onto the bonds array, so when the bonds array gets saved into the DB, the next time the data migration step gets run (e.g. on page refresh) all those bondN properties will be pushed onto the now populated bonds list.

Steps to Reproduce:

  1. Load the attached world.
    • Note: The Gamemaster password for this world is just blank.
  2. Change FP for the aaaaa actor to a number other than a 3 then press tab to make sure the value gets persisted to the db.
    • Due to some other bug here if you attempt to change the number to a 3 then the value will immediately revert back to a 5. Changing to a non-3 number just once will fix whatever issue it is (presumably some uninitialized value?)
  3. Refresh the page.
  4. After refresh open the aaaaa actor and you should see that the FP has been reset to 5.
  5. Open the bbbbb actor.
  6. Click the "+" to add a new bond. It doesn't matter if you populate the bond field or not.
  7. Refresh the page.
  8. After refresh open the bbbbb actor and you will now see the previous bonds duplicated below the new row you added in (6)

Expected behavior:
Expected FP Behavior: FP should remain to whatever you changed them to in (2).
Expected Bonds Behavior: Bonds should not duplicate themselves.

Attachments (if applicable):
aaa.tar.gz

@spyrella
Copy link
Collaborator

@Shourn Shourn assigned Shourn and unassigned spyrella Feb 27, 2024
@Shourn
Copy link
Collaborator

Shourn commented Feb 27, 2024

I'm sad to say this is a larger problem than it appears, probably requiring some sort of dedicated mechanism to migrate the database.
Thankfully it appears that there is simple workaround for these problems: Duplicating the affected Actors

A bit more details:
The problem is caused by outdated source data being stored in the server database.
The DataModel::migrateData API allows us to "fix" old data clientside, but it lacks a way to push these fixes to the database.
So each time we "fix" the data clientside, we are actually overwriting legit data.
This is caused by FoundryVTT using differential updates, which means that deletions have to be pushed to the database explicitly and will not get picked up automatically.
By duplicating, a snapshot of the clientside data is used to create the duplicate, which does not contain the problematic fields (because we removed them during migration).

Foundry should add frameworks to support both client- and serverside migrations in V12.
With this in mind and a simple workaround present, I feel this is not worth the time and effort of implementation at this time.

@spyrella spyrella added the bug Something isn't working label Aug 29, 2024
@Shourn
Copy link
Collaborator

Shourn commented Jan 12, 2025

Closing this since it only affects extremely old data.

@Shourn Shourn closed this as completed Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants