fix: New installs would have multiple entries in dbSchema table #4460

Merged
merged 1 commit into from Sep 16, 2016

Projects

None yet

4 participants

@laf
Member
laf commented Sep 16, 2016

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

On new installs, entries in the DB would continuously run inserting new versions from 118 until the current. This fixes that behaviour and fixes existing installs which may be 'stuck'.

@laf laf fix: New installs would have multiple entries in dbSchema table
82187cc
@scrutinizer-notifier

The inspection completed: No new issues

@@ -153,6 +153,9 @@
$db_rev = $filename;
if ($insert) {
dbInsert(array('version' => $db_rev), 'dbSchema');
+ if ($db_rev >= 6) {
+ $insert = 0;
@murrant
murrant Sep 16, 2016 Contributor

Shouldn't this be before the $insert check?

@laf
laf Sep 16, 2016 Member

We have to avoid the first 5 files as version doesn't exist in dbSchema until 006.sql.

@murrant
murrant Sep 16, 2016 Contributor

Yeah, but this code doesn't do that to my eye, it just sets $insert = 0, which is not used anywhere.

@laf
laf Sep 16, 2016 Member

Eh, we're in a loop at this stage for each file, so we set $insert = 0 when we hit $db_rev 6 and then on the next file we don't insert anymore - we update.

@laf laf added Bug Schema labels Sep 16, 2016
@murrant
Contributor
murrant commented Sep 16, 2016

Ah, I should have read up further. Sorry.

@murrant murrant merged commit 45e41ad into librenms:master Sep 16, 2016

2 checks passed

Auto-Deploy Build finished.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@crcro crcro added a commit to crcro/librenms that referenced this pull request Sep 17, 2016
@laf @crcro laf + crcro fix: New installs would have multiple entries in dbSchema table (#4460) 506adac
@laf laf deleted the laf:schema-version-fix branch Jan 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment