Skip to content

Let the 2.0.0 update SQL run again after an interrupted update (B5) - #253

Open
codeling wants to merge 1 commit into
ccr-c4633bb2-v97st1-loginonlyfrom
ccr-c4633bb2-v97st1-upgrade-sql
Open

codeling wants to merge 1 commit into
ccr-c4633bb2-v97st1-loginonlyfrom
ccr-c4633bb2-v97st1-upgrade-sql

Conversation

@codeling

@codeling codeling commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Stack 3/4 for the 2.0.0 release (#250), based on #252. Review only the top commit.

Problem

If an update stops in the middle of sql/updates/2.0.0.sql, the schema version stays at 1.4.3. A likely cause is that converting a large failedlogin table to utf8mb4 takes longer than the request is allowed to run; that table was never purged by default before 2.0. The next attempt then runs the file again from the start, and its first statement, ADD COLUMN attempts, fails with "Duplicate column name". Every further attempt stops at the same place, so the site can't be updated any more.

Change

The ADD COLUMN and ADD INDEX statements, which MySQL can't make conditional, are marked /** CAN FAIL **/. Joomla's installer has supported this marker since 4.2 (Installer::parseSchemaUpdates()) and carries on if such a statement fails. The other statements already work on tables they changed before: CONVERT TO, CREATE TABLE IF NOT EXISTS, and INSERT … ON DUPLICATE KEY. A comment at the top of the file explains the rule.

Tests

  • tests/Unit/UpdateSqlTest.php: in every update file from 2.0.0 on, each statement that can't run twice (ADD/DROP/RENAME of columns, indexes or keys) carries the marker, placed where Joomla looks for it, and each CREATE TABLE has IF NOT EXISTS. This also guards later update files.
  • tests/Integration/UpdateSqlTest.php: sets the plugin's schema version back to 1.4.3, runs the update through Joomla's own Installer::parseSchemaUpdates() on tables that already have every change, then checks that it succeeds and records the new version. It is skipped on PostgreSQL, which has no update SQL yet.

Both fail without the markers and pass with them. The full suite passes locally on Joomla 5.4.10 with MySQL 8.4 and PostgreSQL 16. Still open: a real upgrade of a large 1.5.2 site with a timeout (H1/H2 in #250).

🤖 Generated with Claude Code

https://claude.ai/code/session_01AFJFMMUpch4LGexEiXN8Nc

If an update stops in the middle of sql/updates/2.0.0.sql - converting a
large failed login table to utf8mb4 can take longer than a request may -
the schema version stays at 1.4.3 and the next attempt runs the file from
the start. Its first statement, ADD COLUMN attempts, then fails ("Duplicate
column name"), so every further attempt stopped there too and the site
could not be updated any more.

The ADD COLUMN and ADD INDEX statements, which MySQL can't make conditional,
are marked CAN FAIL (supported by Joomla's installer since 4.2); everything
else in the file already works on tables it changed before. A unit test
checks that every non-repeatable statement in the update files from 2.0.0
on is marked, and an integration test runs the update through Joomla's
installer on tables which already have all its changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFJFMMUpch4LGexEiXN8Nc
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.

2 participants