Skip to content

Comments

Fix vxDelta table creation failure on MariaDB with NO_ZERO_DATE#157

Draft
Copilot wants to merge 2 commits into3.xfrom
copilot/fix-modx-versionx-delta-table
Draft

Fix vxDelta table creation failure on MariaDB with NO_ZERO_DATE#157
Copilot wants to merge 2 commits into3.xfrom
copilot/fix-modx-versionx-delta-table

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

When NO_ZERO_DATE is in the active SQL mode, creating modx_versionx_delta fails because MySQL/MariaDB silently assigns DEFAULT '0000-00-00 00:00:00' to any TIMESTAMP NOT NULL column lacking an explicit default — and then rejects that zero-date default as invalid.

Changes

  • Schema & map: Changed time_start and time_end from null="false" to null="true" in both versionx.mysql.schema.xml and vxdelta.map.inc.php. This shifts the implicit column default from the forbidden '0000-00-00 00:00:00' to NULL, which is valid under all SQL modes.
<!-- before -->
<field key="time_start" dbtype="timestamp" phptype="timestamp" null="false" />
<field key="time_end"   dbtype="timestamp" phptype="timestamp" null="false" />

<!-- after -->
<field key="time_start" dbtype="timestamp" phptype="timestamp" null="true" />
<field key="time_end"   dbtype="timestamp" phptype="timestamp" null="true" />

The existing alterField calls for both columns in tables.resolver.php already handle the upgrade path for existing installations.

Original prompt

This section details on the original issue you should resolve

<issue_title>Creation of modx_versionx_delta table fails on MariaDB 10.4 with NO_ZERO_DATE</issue_title>
<issue_description>

Summary

When installing or upgrading to VersionX 3.3.0 on MODX Revolution 2.8.8 with MariaDB 10.4.34 running strict SQL modes including NO_ZERO_DATE, the install fails while creating the modx_versionx_delta table with:

ERROR 1067 (42000): Invalid default value for 'time_end'

This occurs:

  • when upgrading from VersionX 2.x, and
  • on a fresh installation on a brand-new MODX 2.8.8 site with no previous VersionX installed.

Environment

  • MODX: 2.8.8
  • VersionX: 3.3.0 (installed via MODX.com provider)
  • DB: MariaDB 10.4.34
  • sql_mode (global and session):
STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

(Output from SELECT @@GLOBAL.sql_mode; and SHOW VARIABLES LIKE 'sql_mode';)

Steps to Reproduce

A) Upgrade path

  1. In MODX (2.8.8) Package Manager, upgrade VersionX to 3.3.0 (from MODX.com provider).
  2. Installation fails during table creation.

B) Fresh install path (also fails)

  1. Use a clean MODX 2.8.8 instance. Ensure no VersionX transports exist under core/packages/ (deleted/empty).
  2. In Package Manager, download VersionX 3.3.0 from the MODX.com provider.
  3. Install; creation of modx_versionx_delta fails with the same error.

Actual Result

Installer error:

Could not create table `modx_versionx_delta` SQL: CREATE TABLE `modx_versionx_delta` (`id` INTEGER unsigned NOT NULL AUTO_INCREMENT, `principal_package` VARCHAR(128) NOT NULL DEFAULT 'core', `principal_class` VARCHAR(128) NOT NULL, `principal` INT(10) unsigned NOT NULL DEFAULT '0', `type_class` VARCHAR(128) NOT NULL, `milestone` VARCHAR(128) NOT NULL DEFAULT '', `time_start` TIMESTAMP NOT NULL, `time_end` TIMESTAMP NOT NULL, PRIMARY KEY (`id`), INDEX `principal_class` (`principal_class`), INDEX `principal` (`principal`), INDEX `time_start` (`time_start`), INDEX `time_end` (`time_end`)) ENGINE=InnoDB ERROR: Array ( [0] => 42000 [1] => 1067 [2] => Invalid default value for 'time_end' ) 

Suspected Cause

In Commit 0a65b02, the explicit defaults for start_time and end_time are removed. According to the MySQL docs:

TIMESTAMP columns following the first one, if not explicitly declared with the NULL attribute or an explicit DEFAULT attribute, are automatically declared as DEFAULT '0000-00-00 00:00:00' (the “zero” timestamp). For inserted rows that specify no explicit value for such a column, the column is assigned '0000-00-00 00:00:00' and no warning occurs.

Depending on whether strict SQL mode or the NO_ZERO_DATE SQL mode is enabled, a default value of '0000-00-00 00:00:00' may be invalid. Be aware that the TRADITIONAL SQL mode includes strict mode and NO_ZERO_DATE. See Section 5.1.10, “Server SQL Modes”. </issue_description>

<agent_instructions>In 0a65b02 we removed explicit defaults to fix an issue on mariadb, instead handling setting the values explicitly in code. Why would this now refuse to create the table without a default? </agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…MP fields

Co-authored-by: Mark-H <312944+Mark-H@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix creation of modx_versionx_delta table in MariaDB 10.4 Fix vxDelta table creation failure on MariaDB with NO_ZERO_DATE Feb 19, 2026
Copilot AI requested a review from Mark-H February 19, 2026 10:42
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.

Creation of modx_versionx_delta table fails on MariaDB 10.4 with NO_ZERO_DATE

2 participants