Skip to content

Commit

Permalink
[5] Sync the sequence for pgsql after the root user is created (jooml…
Browse files Browse the repository at this point in the history
…a#44324)

* synch the sequence

* cs

* Update installation/src/Model/ConfigurationModel.php

Co-authored-by: Richard Fath <[email protected]>

* Update installation/src/Model/ConfigurationModel.php

Co-authored-by: Richard Fath <[email protected]>

---------

Co-authored-by: Richard Fath <[email protected]>
  • Loading branch information
alikon and richard67 authored Oct 22, 2024
1 parent c59046d commit a28c352
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions installation/src/Model/ConfigurationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,18 @@ private function createRootUser($options, $db)

try {
$db->execute();

// Synch the sequence if pgsql
if (($db->getServerType() === 'postgresql') && (!$result)) {
$query = $db->getQuery(true)
->select('MAX(' . $db->quoteName('id') . ') + 1 AS ' . $db->quoteName('id'))
->from($db->quoteName('#__users'));
$db->setQuery($query);
$result = $db->loadResult();

$db->setQuery('SELECT setval(' . $db->quote('#__users_id_seq') . ', ' . $result . ', false)')
->execute();
}
} catch (\RuntimeException $e) {
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');

Expand Down

0 comments on commit a28c352

Please sign in to comment.