fix: preflight schema check prevents duplicate column errors on upgrade#1183
Merged
bcordis merged 2 commits intodevelopmentfrom Mar 19, 2026
Merged
fix: preflight schema check prevents duplicate column errors on upgrade#1183bcordis merged 2 commits intodevelopmentfrom
bcordis merged 2 commits intodevelopmentfrom
Conversation
… upgrade When upgrading from 10.0.x to 10.2.x, MySQL ALTER TABLE ADD COLUMN statements fail if columns already exist (partial upgrade, DB restore, or retry after failed install). The new ensureSchemaReady() method runs in preflight() before Joomla's schema updater and pre-adds any missing columns, making the migration SQL files safe to re-run. Covers all columns added in 10.1.0 and 10.3.0 migrations across 14 tables: audit columns, checked_out, location_id, bible_version, image, platform stats, podcast iTunes fields, and org_name. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ce4ccac to
430d873
Compare
Parse the currently installed install.mysql.utf8.sql to determine what columns each table should have at the installed version. Compare against the live DB and drop any extra columns that are leftovers from a failed partial upgrade. This restores the DB to a clean state so Joomla's migration SQL (ALTER TABLE ADD COLUMN) won't fail on duplicates. No hardcoded column lists — the install SQL file IS the schema reference for the installed version. Works for any version-to-version upgrade path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
430d873 to
b4b0f98
Compare
bcordis
added a commit
that referenced
this pull request
Mar 19, 2026
…de (#1183) * fix: add preflight schema check to prevent duplicate column errors on upgrade When upgrading from 10.0.x to 10.2.x, MySQL ALTER TABLE ADD COLUMN statements fail if columns already exist (partial upgrade, DB restore, or retry after failed install). The new ensureSchemaReady() method runs in preflight() before Joomla's schema updater and pre-adds any missing columns, making the migration SQL files safe to re-run. Covers all columns added in 10.1.0 and 10.3.0 migrations across 14 tables: audit columns, checked_out, location_id, bible_version, image, platform stats, podcast iTunes fields, and org_name. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: preflight schema check using install SQL as version reference Parse the currently installed install.mysql.utf8.sql to determine what columns each table should have at the installed version. Compare against the live DB and drop any extra columns that are leftovers from a failed partial upgrade. This restores the DB to a clean state so Joomla's migration SQL (ALTER TABLE ADD COLUMN) won't fail on duplicates. No hardcoded column lists — the install SQL file IS the schema reference for the installed version. Works for any version-to-version upgrade path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Fixes installation failure when upgrading between versions caused by MySQL
ALTER TABLE ADD COLUMNfailing on columns that already exist from a previous partial upgrade attempt.Problem
MySQL's
ALTER TABLE ADD COLUMNis not idempotent — it throws "Duplicate column" if the column already exists. Joomla's schema updater aborts on the first SQL error and marks the install as failed, but the component files have already been copied. This leaves the site in a broken state: new PHP code but old database schema.This happens when:
Fix
New
ensureSchemaReady()method runs inpreflight()before Joomla copies files or runs the schema updater:install.mysql.utf8.sql(still on disk from the old version)Why this approach
<schemas>stays in XML, migration SQL files unchangedFlow
Test plan
🤖 Generated with Claude Code