fix initial install issues with new sql updater

git-svn-id: http://www.observium.org/svn/observer/trunk@2878 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans 2012-02-19 17:14:57 +00:00
parent 9a9abe032a
commit cfb886a394

View File

@ -34,6 +34,8 @@ if ($db_rev = @dbFetchCell("SELECT version FROM `dbSchema`")) {} else
$db_rev = 0;
}
$insert = 0;
# For transition from old system
if ($old_rev = @dbFetchCell("SELECT revision FROM `dbSchema`"))
{
@ -46,8 +48,7 @@ if ($old_rev = @dbFetchCell("SELECT revision FROM `dbSchema`"))
if ($old_rev < 2804) { $db_rev = 4; }
if ($old_rev < 2827) { $db_rev = 5; }
dbQuery("ALTER TABLE `dbSchema` ADD `version` INT NOT NULL");
dbInsert(array('version' => $db_rev), 'dbSchema');
$insert = 1;
}
$updating = 0;
@ -118,7 +119,12 @@ foreach ($filelist as $file)
if ($updating)
{
dbUpdate(array('version' => $db_rev), 'dbSchema');
if ($insert)
{
dbInsert(array('version' => $db_rev), 'dbSchema');
} else {
dbUpdate(array('version' => $db_rev), 'dbSchema');
}
echo "-- Done\n";
}