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

Backwards compatible migrations #54

Merged
merged 5 commits into from
Jun 19, 2024
Merged

Conversation

nezuo
Copy link
Owner

@nezuo nezuo commented Jun 19, 2024

Migrations can now be marked as backwards compatible. Backwards compatibility is transitive, for example, if v2 is backwards compatible with v1 and v3 is backwards compatible with v2, v3 is also backwards compatible with v1.

When a document is loaded with a migrationVersion greater than the latest migration version the server has, the document will be loaded as long as it is backwards compatible with the server version.

A lastCompatibleVersion is saved to a document when it's created or when it's migrated to a new version. If lastCompatibleVersion is nil because the document existed before this feature was added and hasn't had a migration since, Lapis will assume that the document isn't backwards compatible with any version.

If a migration's backwardsCompatible value is changed after the fact, it won't affect documents until and unless the documents are created for the first time or they are migrated to a new version.

I chose this behavior because if you joined a server with the old backwardsCompatible value after joining a server with the new one, it would recalculate lastCompatibleVersion to be an incorrect version.

The alternative that was ruled out was recalculating lastCompatibleVersion every time a document was loaded.

@nezuo nezuo merged commit 084ed71 into master Jun 19, 2024
@nezuo nezuo deleted the backwards-compatible-migrations branch June 19, 2024 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant