From 2b2b6f2e41f58ab11a450f4f7a4e547902f7db42 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 1 May 2024 21:01:12 +0200 Subject: [PATCH] SQLite 3.35.0 introduced drop column support see https://www.sqlite.org/releaselog/3_35_0.html --- lib/Data/Database.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/Data/Database.php b/lib/Data/Database.php index 541e6a4e..2a4b470c 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -915,10 +915,21 @@ class Database extends AbstractData } // no break, continue with updates for all newer versions case '1.7.2': - $this->_db->exec( - 'ALTER TABLE "' . $this->_sanitizeIdentifier('paste') . - '" DROP COLUMN "postdate"' - ); + $supportsDropColumn = true; + if ($this->_type === 'sqlite') { + try { + $row = $this->_select('SELECT sqlite_version() AS "v"', array(), true); + $supportsDropColumn = version_compare($row['v'], '3.35.0', '>='); + } catch (PDOException $e) { + $supportsDropColumn = false; + } + } + if ($supportsDropColumn) { + $this->_db->exec( + 'ALTER TABLE "' . $this->_sanitizeIdentifier('paste') . + '" DROP COLUMN "postdate"' + ); + } // no break, continue with updates for all newer versions default: $this->_exec(