Run database upgrades when setting up tests
This commit is contained in:
parent
2a53241ba3
commit
288473e4fc
|
@ -38,12 +38,6 @@ class UpgradeManager
|
||||||
$schemaVersion = Application_Model_Preference::GetSchemaVersion();
|
$schemaVersion = Application_Model_Preference::GetSchemaVersion();
|
||||||
$supportedSchemaVersions = self::getSupportedSchemaVersions();
|
$supportedSchemaVersions = self::getSupportedSchemaVersions();
|
||||||
return !in_array($schemaVersion, $supportedSchemaVersions);
|
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
|
* allowing child classes to overwrite _runUpgrade to reduce duplication
|
||||||
*/
|
*/
|
||||||
public function upgrade() {
|
public function upgrade() {
|
||||||
assert($this->checkIfUpgradeSupported());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// $this->toggleMaintenanceScreen(true);
|
// $this->toggleMaintenanceScreen(true);
|
||||||
|
|
||||||
|
@ -200,6 +192,7 @@ abstract class AirtimeUpgrader
|
||||||
// $this->toggleMaintenanceScreen(false);
|
// $this->toggleMaintenanceScreen(false);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
// $this->toggleMaintenanceScreen(false);
|
// $this->toggleMaintenanceScreen(false);
|
||||||
|
Logging::error('Error in upgrade: '. $e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,13 +229,12 @@ abstract class AirtimeUpgrader
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _getDbValues() {
|
protected function _getDbValues() {
|
||||||
$airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
|
$config = Config::getConfig();
|
||||||
$values = parse_ini_file($airtimeConf, true);
|
|
||||||
|
|
||||||
$this->username = $values['database']['dbuser'];
|
$this->username = $config['dsn']['username'];
|
||||||
$this->password = $values['database']['dbpass'];
|
$this->password = $config['dsn']['password'];
|
||||||
$this->host = $values['database']['host'];
|
$this->host = $config['dsn']['hostspec'];
|
||||||
$this->database = $values['database']['dbname'];
|
$this->database = $config['dsn']['database'];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _runUpgrade() {
|
protected function _runUpgrade() {
|
||||||
|
|
|
@ -235,23 +235,8 @@ class AirtimeInstall
|
||||||
}
|
}
|
||||||
AirtimeInstall::$databaseTablesCreated = true;
|
AirtimeInstall::$databaseTablesCreated = true;
|
||||||
}
|
}
|
||||||
public static function BypassMigrations($dir, $version)
|
public final static function UpdateDatabaseTables() {
|
||||||
{
|
UpgradeManager::doUpgrade();
|
||||||
$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 static function SetAirtimeVersion($p_version)
|
public static function SetAirtimeVersion($p_version)
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,7 +122,8 @@ class TestHelper
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Create all the database tables
|
//Create all the database tables
|
||||||
AirtimeInstall::createDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
|
AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
|
||||||
|
AirtimeInstall::UpdateDatabaseTables();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue