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

Migrating old data #26

Closed
sidharthv96 opened this issue Aug 28, 2022 · 4 comments · Fixed by #29
Closed

Migrating old data #26

sidharthv96 opened this issue Aug 28, 2022 · 4 comments · Fixed by #29

Comments

@sidharthv96
Copy link
Contributor

Before the upgrade, I wrote a test to make sure existing data isn't affected when a user loads the site with the new version.
https://github.com/mermaid-js/mermaid-live-editor/blob/04b898ee5441353ff3cde3a6f3f97dee26153b37/cypress/e2e/history.spec.ts#L17-L43

But this test is failing with v2, but passes in v1.
Unless there is a clear path for migration, this is a serious issue that could result in tricky situations.

@MacFJA
Copy link
Owner

MacFJA commented Aug 28, 2022

It won't be to hard to handle your case.

The new serialization library add some special data during the serialization.
And right now if those special data are missing, the library return the raw text.

I can change it to return the raw JSON object instead of the text.
So, if the old data was just a plain JSON encoded data, the data will be retrieve (and later be re-encoded with the new format)


But for more complex data, like class serialization, it will be more difficult as the old library and the new one operate differently.

@MacFJA
Copy link
Owner

MacFJA commented Aug 28, 2022

Another option is to allow custom serialization library (so the old one can be used, or even a simple JSON.stringify and JSON.parse) 🤔

@sidharthv96
Copy link
Contributor Author

Custom serialisation is a good idea. But if the library can handle the migration from old format automatically, that would mean the switch to V2 will be much smoother for a lot of Devs.

We should also add a prominent warning in the changelog that data loss is a possibility when upgrading.

@MacFJA
Copy link
Owner

MacFJA commented Sep 4, 2022

@sidharthv96 The new version 2.1.0 is compatible with plain JSON (any data saved before 1.3.0 and data from 1.3.0 that are not Javascript classes)

The version also allow to change the serialization functions used: documentation here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants