diff --git a/incl/configProcessing.inc.php b/incl/configProcessing.inc.php index 2298578..8f57045 100644 --- a/incl/configProcessing.inc.php +++ b/incl/configProcessing.inc.php @@ -17,8 +17,8 @@ */ -const BB_VERSION = "1801"; -const BB_VERSION_READABLE = "1.8.0.1"; +const BB_VERSION = "1802"; +const BB_VERSION_READABLE = "1.8.0.2"; const CONFIG_PATH = __DIR__ . '/../data/config.php'; const AUTHDB_PATH = __DIR__ . '/../data/users.db'; diff --git a/incl/db.inc.php b/incl/db.inc.php index a9c1942..3dc1dda 100755 --- a/incl/db.inc.php +++ b/incl/db.inc.php @@ -169,7 +169,7 @@ private function initDb() { self::checkPermissions(); $this->db = new SQLite3($CONFIG->DATABASE_PATH); $this->db->busyTimeout(5000); - $this->db->exec("CREATE TABLE IF NOT EXISTS Barcodes(id INTEGER PRIMARY KEY, barcode TEXT NOT NULL, name TEXT NOT NULL, possibleMatch INTEGER, amount INTEGER NOT NULL, requireWeight INTEGER, bestBeforeInDays INTEGER, price TEXT)"); + $this->db->exec("CREATE TABLE IF NOT EXISTS Barcodes(id INTEGER PRIMARY KEY, barcode TEXT NOT NULL, name TEXT NOT NULL, possibleMatch INTEGER, amount INTEGER NOT NULL, requireWeight INTEGER, bestBeforeInDays INTEGER, price TEXT, bbServerAltNames TEXT)"); $this->db->exec("CREATE TABLE IF NOT EXISTS Tags(id INTEGER PRIMARY KEY, tag TEXT NOT NULL, itemId INTEGER NOT NULL)"); $this->db->exec("CREATE TABLE IF NOT EXISTS TransactionState(id INTEGER PRIMARY KEY, currentState TINYINT NOT NULL, since INTEGER NOT NULL)"); $this->db->exec("CREATE TABLE IF NOT EXISTS BarcodeLogs(id INTEGER PRIMARY KEY, log TEXT NOT NULL)"); diff --git a/incl/modules/dbUpgrade.php b/incl/modules/dbUpgrade.php index 9c5fa81..0683584 100644 --- a/incl/modules/dbUpgrade.php +++ b/incl/modules/dbUpgrade.php @@ -121,6 +121,12 @@ public function upgradeBarcodeBuddy(int $previousVersion) { $this->db->exec("ALTER TABLE Barcodes ADD COLUMN bbServerAltNames TEXT"); $this->isSupportedGrocyVersionOrDie(); } + if ($previousVersion < 1802) { + //In v1800 the db was not initialised properly for new installations. This has to be done again + $columnInfo = $this->db->querySingle("SELECT COUNT(*) AS CNTREC FROM pragma_table_info('Barcodes') WHERE name='bbServerAltNames'"); + if ($columnInfo == 0) + $this->db->exec("ALTER TABLE Barcodes ADD COLUMN bbServerAltNames TEXT"); + } RedisConnection::updateCache(); }