Skip to content

Commit

Permalink
Fix migration failure with MariaDB due to syntax error (#2917)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadzpogi authored Feb 18, 2025
1 parent f56c237 commit f868269
Showing 1 changed file with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,25 @@ class UpsertCoreEmergencyAlertInModule extends AbstractMigration
{
public function change(): void
{
// Insert or update core-emergency-alert into the module table
$this->execute('
INSERT INTO `module` (`moduleId`, `enabled`, `previewEnabled`, `defaultDuration`, `settings`)
VALUES (\'core-emergency-alert\', \'1\', \'1\', \'60\', NULL) AS newRow
ON DUPLICATE KEY UPDATE
`enabled` = newRow.enabled,
`previewEnabled` = newRow.previewEnabled,
`defaultDuration` = newRow.defaultDuration,
`settings` = newRow.settings;
');
// Check if the core-emergency-alert row exists
$row = $this->fetchRow("SELECT * FROM `module` WHERE `moduleId` = 'core-emergency-alert'");

if (!$row) {
// Row does not exist, insert new row
$this->execute("
INSERT INTO `module` (`moduleId`, `enabled`, `previewEnabled`, `defaultDuration`, `settings`)
VALUES ('core-emergency-alert', '1', '1', '60', NULL)
");
} else {
// Row exists, update existing row
$this->execute("
UPDATE `module`
SET `enabled` = '1',
`previewEnabled` = '1',
`defaultDuration` = '60',
`settings` = NULL
WHERE `moduleId` = 'core-emergency-alert'
");
}
}
}

0 comments on commit f868269

Please sign in to comment.