Skip to content

Commit

Permalink
devel: bump db version using date from filename (we dont need repeata…
Browse files Browse the repository at this point in the history
…ble work to be done in upgradedb.php), also use transactions for all upgrade scripts
  • Loading branch information
interduo committed Aug 23, 2022
1 parent c11de6f commit 4d6a912
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion devel/dbinfo_version_bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ sed -i -e "s/^define('DBVERSION', '\([0-9]\+\)');/define('DBVERSION', '$1');/g"

for dbdriver in mysql postgres; do
if [ ! -f "${LMSDIR}/lib/upgradedb/${dbdriver}.$1.php" ]; then
sed -e "s/%version%/$1/g" ${CWD}/upgradedb-template.php >${LMSDIR}/lib/upgradedb/${dbdriver}.$1.php
cp ${CWD}/upgradedb-template.php ${LMSDIR}/lib/upgradedb/${dbdriver}.$1.php
fi
done
6 changes: 0 additions & 6 deletions devel/upgradedb-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,3 @@
* USA.
*
*/

$this->BeginTrans();

$this->Execute("UPDATE dbinfo SET keyvalue = ? WHERE keytype = ?", array('%version%', 'dbversion'));

$this->CommitTrans();
17 changes: 16 additions & 1 deletion lib/LMSDB_common.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,22 @@ public function UpgradeDb($dbver = DBVERSION, $pluginclass = null, $libdir = nul
if (!empty($pendingupgrades)) {
sort($pendingupgrades);
foreach ($pendingupgrades as $upgrade) {
include($libdir . DIRECTORY_SEPARATOR . 'upgradedb' . DIRECTORY_SEPARATOR . $filename_prefix . '.' . $upgrade . '.php');
// from 2022-08-22 we don't need to add UPDATE
// and dbinfo query and transactions Start/Commit
if ($upgrade >= 2022082200) {
$this->BeginTrans();
include($libdir . DIRECTORY_SEPARATOR . 'upgradedb'
. DIRECTORY_SEPARATOR . $filename_prefix . '.' . $upgrade . '.php');
$this->Execute(
'UPDATE dbinfo SET keyvalue = ? WHERE keytype = ?',
array($upgrade, 'dbversion')
);
$this->CommitTrans();
} else {
include($libdir . DIRECTORY_SEPARATOR . 'upgradedb'
. DIRECTORY_SEPARATOR . $filename_prefix . '.' . $upgrade . '.php');
}

if (empty($this->errors)) {
$lastupgrade = $upgrade;
} else {
Expand Down

0 comments on commit 4d6a912

Please sign in to comment.