Skip to content

Commit

Permalink
Corrected invalid database init for new installs #110
Browse files Browse the repository at this point in the history
  • Loading branch information
Forceu committed Jan 26, 2021
1 parent c9a3f63 commit f8dee69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions incl/configProcessing.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion incl/db.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
Expand Down
6 changes: 6 additions & 0 deletions incl/modules/dbUpgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit f8dee69

Please sign in to comment.