Skip to content

feature: treat NULL install schema version as snapshot#719

Open
anonymoususer72041 wants to merge 2 commits intoopencats:masterfrom
anonymoususer72041:feature/schema-snapshot-module-schema-version
Open

feature: treat NULL install schema version as snapshot#719
anonymoususer72041 wants to merge 2 commits intoopencats:masterfrom
anonymoususer72041:feature/schema-snapshot-module-schema-version

Conversation

@anonymoususer72041
Copy link
Contributor

Summary

This PR makes fresh installs from db/cats_schema.sql resilient to schema snapshot drift by allowing the install module’s module_schema.version to be NULL initially.

When module_schema.version for install is NULL (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 from modules/install/Schema.php, without executing any install migrations.

The schema snapshot seed in db/cats_schema.sql is adjusted accordingly by omitting the version value for the install entry in module_schema, so new databases start with install.version = NULL by design.

Motivation

db/cats_schema.sql is a snapshot that can already include the latest structural changes, but if the seeded module_schema.version lags 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 NULL version for the install module 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 the module_schema.version value in db/cats_schema.sql. All subsequent upgrades continue to run via the existing migration mechanism as before.

@anonymoususer72041
Copy link
Contributor Author

@RussH this is also a quick win that will reduce further development work (including on already opened PRs).

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