Run database upgrades when setting up tests

This commit is contained in:
Lucas Bickel 2017-03-10 18:27:11 +01:00
parent 2a53241ba3
commit 288473e4fc
3 changed files with 10 additions and 32 deletions

View File

@ -38,12 +38,6 @@ class UpgradeManager
$schemaVersion = Application_Model_Preference::GetSchemaVersion();
$supportedSchemaVersions = self::getSupportedSchemaVersions();
return !in_array($schemaVersion, $supportedSchemaVersions);
// We shouldn't run the upgrade as a side-effect of this function!
/*
if ($upgradeNeeded) {
self::doUpgrade();
}
*/
}
/**
@ -187,8 +181,6 @@ abstract class AirtimeUpgrader
* allowing child classes to overwrite _runUpgrade to reduce duplication
*/
public function upgrade() {
assert($this->checkIfUpgradeSupported());
try {
// $this->toggleMaintenanceScreen(true);
@ -200,6 +192,7 @@ abstract class AirtimeUpgrader
// $this->toggleMaintenanceScreen(false);
} catch(Exception $e) {
// $this->toggleMaintenanceScreen(false);
Logging::error('Error in upgrade: '. $e->getMessage());
return false;
}
@ -236,13 +229,12 @@ abstract class AirtimeUpgrader
}
protected function _getDbValues() {
$airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
$values = parse_ini_file($airtimeConf, true);
$config = Config::getConfig();
$this->username = $values['database']['dbuser'];
$this->password = $values['database']['dbpass'];
$this->host = $values['database']['host'];
$this->database = $values['database']['dbname'];
$this->username = $config['dsn']['username'];
$this->password = $config['dsn']['password'];
$this->host = $config['dsn']['hostspec'];
$this->database = $config['dsn']['database'];
}
protected function _runUpgrade() {

View File

@ -235,23 +235,8 @@ class AirtimeInstall
}
AirtimeInstall::$databaseTablesCreated = true;
}
public static function BypassMigrations($dir, $version)
{
$appDir = AirtimeInstall::GetAirtimeSrcDir();
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction --add migrations:version $version";
system($command);
}
public static function MigrateTablesToVersion($dir, $version)
{
$appDir = AirtimeInstall::GetAirtimeSrcDir();
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
"--no-interaction migrations:migrate $version";
system($command);
public final static function UpdateDatabaseTables() {
UpgradeManager::doUpgrade();
}
public static function SetAirtimeVersion($p_version)
{

View File

@ -122,7 +122,8 @@ class TestHelper
else
{
//Create all the database tables
AirtimeInstall::createDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
AirtimeInstall::UpdateDatabaseTables();
}
}