Skip to content

Commit

Permalink
Fix modManagerLog MySQL > 5.7.8
Browse files Browse the repository at this point in the history
Add right default value for datatime-type column in modx_manager_log table

Re-up of #15736 with migration
  • Loading branch information
Mark-H committed Feb 10, 2024
1 parent 73bfd27 commit 3e99b2d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 38 deletions.
2 changes: 1 addition & 1 deletion core/model/schema/modx.mysql.schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@

<object class="modManagerLog" table="manager_log" extends="xPDO\Om\xPDOSimpleObject">
<field key="user" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="occurred" dbtype="datetime" phptype="datetime" null="true" default="NULL" />
<field key="occurred" dbtype="datetime" phptype="datetime" null="false" default="CURRENT_TIMESTAMP" />
<field key="action" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
<field key="classKey" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
<field key="item" dbtype="varchar" precision="255" phptype="string" null="false" default="0" />
Expand Down
68 changes: 34 additions & 34 deletions core/src/Revolution/Registry/Db/mysql/modDbRegisterMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class modDbRegisterMessage extends \MODX\Revolution\Registry\Db\modDbRegisterMes
'version' => '3.0',
'table' => 'register_messages',
'extends' => 'xPDO\\Om\\xPDOObject',
'tableMeta' =>
'tableMeta' =>
array (
'engine' => 'InnoDB',
),
'fields' =>
'fields' =>
array (
'topic' => NULL,
'id' => NULL,
Expand All @@ -29,9 +29,9 @@ class modDbRegisterMessage extends \MODX\Revolution\Registry\Db\modDbRegisterMes
'payload' => NULL,
'kill' => 0,
),
'fieldMeta' =>
'fieldMeta' =>
array (
'topic' =>
'topic' =>
array (
'dbtype' => 'integer',
'precision' => '10',
Expand All @@ -40,36 +40,36 @@ class modDbRegisterMessage extends \MODX\Revolution\Registry\Db\modDbRegisterMes
'null' => false,
'index' => 'pk',
),
'id' =>
'id' =>
array (
'dbtype' => 'varchar',
'precision' => '191',
'phptype' => 'string',
'null' => false,
'index' => 'pk',
),
'created' =>
'created' =>
array (
'dbtype' => 'datetime',
'phptype' => 'datetime',
'null' => false,
'index' => 'index',
),
'valid' =>
'valid' =>
array (
'dbtype' => 'datetime',
'phptype' => 'datetime',
'null' => false,
'index' => 'index',
),
'accessed' =>
'accessed' =>
array (
'dbtype' => 'timestamp',
'phptype' => 'timestamp',
'attributes' => 'ON UPDATE CURRENT_TIMESTAMP',
'index' => 'index',
),
'accesses' =>
'accesses' =>
array (
'dbtype' => 'integer',
'precision' => '10',
Expand All @@ -79,7 +79,7 @@ class modDbRegisterMessage extends \MODX\Revolution\Registry\Db\modDbRegisterMes
'default' => 0,
'index' => 'index',
),
'expires' =>
'expires' =>
array (
'dbtype' => 'integer',
'precision' => '20',
Expand All @@ -88,13 +88,13 @@ class modDbRegisterMessage extends \MODX\Revolution\Registry\Db\modDbRegisterMes
'default' => 0,
'index' => 'index',
),
'payload' =>
'payload' =>
array (
'dbtype' => 'mediumtext',
'phptype' => 'string',
'null' => false,
),
'kill' =>
'kill' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
Expand All @@ -104,103 +104,103 @@ class modDbRegisterMessage extends \MODX\Revolution\Registry\Db\modDbRegisterMes
'default' => 0,
),
),
'indexes' =>
'indexes' =>
array (
'PRIMARY' =>
'PRIMARY' =>
array (
'alias' => 'PRIMARY',
'primary' => true,
'unique' => true,
'type' => 'BTREE',
'columns' =>
'columns' =>
array (
'topic' =>
'topic' =>
array (
'length' => '',
'collation' => 'A',
'null' => false,
),
'id' =>
'id' =>
array (
'length' => '',
'collation' => 'A',
'null' => false,
),
),
),
'created' =>
'created' =>
array (
'alias' => 'created',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
'columns' =>
'columns' =>
array (
'created' =>
'created' =>
array (
'length' => '',
'collation' => 'A',
'null' => false,
),
),
),
'valid' =>
'valid' =>
array (
'alias' => 'valid',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
'columns' =>
'columns' =>
array (
'valid' =>
'valid' =>
array (
'length' => '',
'collation' => 'A',
'null' => false,
),
),
),
'accessed' =>
'accessed' =>
array (
'alias' => 'accessed',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
'columns' =>
'columns' =>
array (
'accessed' =>
'accessed' =>
array (
'length' => '',
'collation' => 'A',
'null' => false,
),
),
),
'accesses' =>
'accesses' =>
array (
'alias' => 'accesses',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
'columns' =>
'columns' =>
array (
'accesses' =>
'accesses' =>
array (
'length' => '',
'collation' => 'A',
'null' => false,
),
),
),
'expires' =>
'expires' =>
array (
'alias' => 'expires',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
'columns' =>
'columns' =>
array (
'expires' =>
'expires' =>
array (
'length' => '',
'collation' => 'A',
Expand All @@ -209,9 +209,9 @@ class modDbRegisterMessage extends \MODX\Revolution\Registry\Db\modDbRegisterMes
),
),
),
'aggregates' =>
'aggregates' =>
array (
'Topic' =>
'Topic' =>
array (
'class' => 'MODX\\Revolution\\Registry\\Db\\modDbRegisterTopic',
'local' => 'topic',
Expand Down
6 changes: 3 additions & 3 deletions core/src/Revolution/mysql/modManagerLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class modManagerLog extends \MODX\Revolution\modManagerLog
'fields' =>
array (
'user' => 0,
'occurred' => NULL,
'occurred' => 'CURRENT_TIMESTAMP',
'action' => '',
'classKey' => '',
'item' => '0',
Expand All @@ -38,8 +38,8 @@ class modManagerLog extends \MODX\Revolution\modManagerLog
array (
'dbtype' => 'datetime',
'phptype' => 'datetime',
'null' => true,
'default' => NULL,
'null' => false,
'default' => 'CURRENT_TIMESTAMP',
),
'action' =>
array (
Expand Down
11 changes: 11 additions & 0 deletions setup/includes/upgrades/common/3.1.0-db-changes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

Check failure on line 1 in setup/includes/upgrades/common/3.1.0-db-changes.php

View workflow job for this annotation

GitHub Actions / phpcs

Header blocks must be separated by a single blank line
/**
* Database changes for 3.1
*
* @var modX $modx
* @package setup
*/

$manager = $modx->getManager();

$manager->alterField(\MODX\Revolution\modManagerLog::class, 'occurred');
11 changes: 11 additions & 0 deletions setup/includes/upgrades/mysql/3.1.0-pl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
/**
* Specific upgrades for Revolution 3.1.0-pl
*
* @var modX $modx
* @package setup
* @subpackage upgrades
*/

/* run upgrades common to all db platforms */
include dirname(__DIR__) . '/common/3.1.0-db-changes.php';

0 comments on commit 3e99b2d

Please sign in to comment.