Skip to content

Error check database update in Joomla 4 #36085

@thanhnv37

Description

@thanhnv37

In the sql update file, if I add multiple CHANGE COLUMN in one ALTER TABLE statement.
It will cause error in the page Check Database Updates (In Joomla 4 Backend > System > Database).

For example, if I add the statement below to the file:
sql/updates/4.8.3.sql

ALTER TABLE `#__geekelasticsearch_log_searches`
  CHANGE `first_search` `first_search` DATETIME NULL DEFAULT NULL,
  CHANGE `last_search` `last_search` DATETIME NULL DEFAULT NULL;

The class that build sql check update will generate invalid query as below (libraries/src/Schema/ChangeItem/MysqlChangeItem.php):

SHOW COLUMNS IN `jos_geekelasticsearch_log_searches` WHERE field = 'first_search' AND UPPER(type) = 'DATETIME' AND `default` = NULL, AND `null` = 'YES'

I have to split that sql statement into multiple ones as below to resolve this issue:

ALTER TABLE `#__geekelasticsearch_log_searches` CHANGE `first_search` `first_search` DATETIME NULL DEFAULT NULL;
ALTER TABLE `#__geekelasticsearch_log_searches` CHANGE `last_search` `last_search` DATETIME NULL DEFAULT NULL;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions