J4.x

J4.x:Fix "Database Table Structure NOT Up to Date" before Update

From Joomla! Documentation

Revision as of 00:05, 24 February 2022 by Bembelimen (talk | contribs) (Explain how to fix empty schemas)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Errors reported

When updating Joomla! the database table structure has to be up to date before the process can start.

The "Pre-Update Check for Joomla" complains if this is not the case.

Joomla! 4 - Pre-Update Check - database table structure not up to date

But when you go to 'System - Maintenance - Database' there is no entry available.

Versions affected

General Information

This was reported in any Joomla! 4.x versions.

What is the cause

This is caused by an empty #__schemas table in the database. Most likely this occurs when the Joomla! instance is not installed by the official Joomla! installer but e.g. though an customized script which did not fill in all required data.

How to fix

We fix it by adding the missing value to the table. First we need to know the latest SQL script which is installed. Go to "administrator/components/com_admin/sql/updates/mysql" and get the file name with the highest version. In this example we assume "4.0.3-2021-09-05.sql" is the filename with the highest version. Now we have to add this in our insert query as second value:

INSERT INTO `#__schemas` (`extension_id`, `version_id`) VALUES
(211, '4.0.3-2021-09-05');

or for PostgreSQL:

INSERT INTO "#__schemas" ("extension_id", "version_id") VALUES
(211, '4.0.3-2021-09-05');

Replace "#__" by your database prefix (see Global Configuration) before running the statements.

Then go to "System - Maintenance - Database" and fix the tables.

Now the update should work as expected.