refactor database schema upgrade to support skipping versions
This commit is contained in:
parent
b96c8ae531
commit
99a3e087ed
1 changed files with 73 additions and 76 deletions
|
@ -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,13 +929,11 @@ 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" = ?',
|
||||
array(Controller::VERSION, 'VERSION')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue