feature: treat NULL install schema version as snapshot#719
Open
anonymoususer72041 wants to merge 2 commits intoopencats:masterfrom
Open
feature: treat NULL install schema version as snapshot#719anonymoususer72041 wants to merge 2 commits intoopencats:masterfrom
anonymoususer72041 wants to merge 2 commits intoopencats:masterfrom
Conversation
Contributor
Author
|
@RussH this is also a quick win that will reduce further development work (including on already opened PRs). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes fresh installs from
db/cats_schema.sqlresilient to schema snapshot drift by allowing theinstallmodule’smodule_schema.versionto beNULLinitially.When
module_schema.versionforinstallisNULL(or an empty string), OpenCATS now treats this as a schema snapshot install and self-heals by setting the version to the latest migration ID frommodules/install/Schema.php, without executing any install migrations.The schema snapshot seed in
db/cats_schema.sqlis adjusted accordingly by omitting theversionvalue for theinstallentry inmodule_schema, so new databases start withinstall.version = NULLby design.Motivation
db/cats_schema.sqlis a snapshot that can already include the latest structural changes, but if the seededmodule_schema.versionlags behind, OpenCATS attempts to re-run install migrations on first start. This can lead to failures such as duplicate column or duplicate index errors.By treating a
NULLversion for theinstallmodule as “snapshot is already current” and setting the stored version to the latest migration ID, new installations remain consistent without requiring every new migration to also update themodule_schema.versionvalue indb/cats_schema.sql. All subsequent upgrades continue to run via the existing migration mechanism as before.