Merge pull request #1343 from PrivateBin/db-version-upgrade

refactor database schema upgrade to support skipping versions
This commit is contained in:
El RIDO 2024-05-26 08:40:29 +02:00 committed by GitHub
commit f313578892
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -853,8 +853,7 @@ class Database extends AbstractData
{
$dataType = $this->_getDataType();
$attachmentType = $this->_getAttachmentType();
switch ($oldversion) {
case '0.21':
if (version_compare($oldversion, '0.21', '<=')) {
// create the meta column if necessary (pre 0.21 change)
try {
$this->_db->exec(
@ -902,8 +901,8 @@ class Database extends AbstractData
$this->_sanitizeIdentifier('comment_parent') . '" ON "' .
$this->_sanitizeIdentifier('comment') . '" ("pasteid")'
);
// no break, continue with updates for 0.22 and later
case '1.3':
}
if (version_compare($oldversion, '1.3', '<=')) {
// SQLite doesn't support MODIFY, but it allows TEXT of similar
// size as BLOB and PostgreSQL uses TEXT, so there is no need
// to change it there
@ -913,8 +912,8 @@ class Database extends AbstractData
"\" MODIFY COLUMN \"data\" $attachmentType"
);
}
// no break, continue with updates for all newer versions
case '1.7.2':
}
if (version_compare($oldversion, '1.7.1', '<=')) {
$supportsDropColumn = true;
if ($this->_type === 'sqlite') {
try {
@ -930,8 +929,7 @@ class Database extends AbstractData
'" DROP COLUMN "postdate"'
);
}
// no break, continue with updates for all newer versions
default:
}
$this->_exec(
'UPDATE "' . $this->_sanitizeIdentifier('config') .
'" SET "value" = ? WHERE "id" = ?',
@ -939,4 +937,3 @@ class Database extends AbstractData
);
}
}
}