From f147fb34bb21fc0300f54313d53ddb2df3262e5b Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 3 Nov 2014 16:56:25 -0500 Subject: [PATCH] Cloud storage upgrade script --- .../upgrade_sql/airtime_2.5.9/upgrade.sql | 10 ++ airtime_mvc/application/upgrade/Upgrades.php | 132 ++++++++++++------ 2 files changed, 98 insertions(+), 44 deletions(-) create mode 100644 airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.9/upgrade.sql diff --git a/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.9/upgrade.sql b/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.9/upgrade.sql new file mode 100644 index 000000000..95ad9bab4 --- /dev/null +++ b/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.9/upgrade.sql @@ -0,0 +1,10 @@ +CREATE TABLE cloud_file +( + id serial NOT NULL, + resource_id text NOT NULL, + cc_file_id integer, + CONSTRAINT cloud_file_pkey PRIMARY KEY (id), + CONSTRAINT "cloud_file_FK_1" FOREIGN KEY (cc_file_id) + REFERENCES cc_files (id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE CASCADE +) \ No newline at end of file diff --git a/airtime_mvc/application/upgrade/Upgrades.php b/airtime_mvc/application/upgrade/Upgrades.php index 428d9e2b0..3cc7a47ba 100644 --- a/airtime_mvc/application/upgrade/Upgrades.php +++ b/airtime_mvc/application/upgrade/Upgrades.php @@ -208,47 +208,91 @@ class AirtimeUpgrader254 extends AirtimeUpgrader } class AirtimeUpgrader255 extends AirtimeUpgrader { - protected function getSupportedVersions() { - return array ( - '2.5.4' - ); - } - - public function getNewVersion() { - return '2.5.5'; - } - - public function upgrade($dir = __DIR__) { - Cache::clear(); - assert($this->checkIfUpgradeSupported()); - - $newVersion = $this->getNewVersion(); - - try { - $this->toggleMaintenanceScreen(true); - Cache::clear(); - - // Begin upgrade - $airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf"; - $values = parse_ini_file($airtimeConf, true); - - $username = $values['database']['dbuser']; - $password = $values['database']['dbpass']; - $host = $values['database']['host']; - $database = $values['database']['dbname']; - - passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_" - .$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\""); - - Application_Model_Preference::SetAirtimeVersion($newVersion); - Cache::clear(); - - $this->toggleMaintenanceScreen(false); - - return true; - } catch(Exception $e) { - $this->toggleMaintenanceScreen(false); - throw $e; - } - } -} \ No newline at end of file + protected function getSupportedVersions() { + return array ( + '2.5.4' + ); + } + + public function getNewVersion() { + return '2.5.5'; + } + + public function upgrade($dir = __DIR__) { + Cache::clear(); + assert($this->checkIfUpgradeSupported()); + + $newVersion = $this->getNewVersion(); + + try { + $this->toggleMaintenanceScreen(true); + Cache::clear(); + + // Begin upgrade + $airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf"; + $values = parse_ini_file($airtimeConf, true); + + $username = $values['database']['dbuser']; + $password = $values['database']['dbpass']; + $host = $values['database']['host']; + $database = $values['database']['dbname']; + + passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_" + .$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\""); + + Application_Model_Preference::SetAirtimeVersion($newVersion); + Cache::clear(); + + $this->toggleMaintenanceScreen(false); + + return true; + } catch(Exception $e) { + $this->toggleMaintenanceScreen(false); + throw $e; + } + } +} + +class AirtimeUpgrader259 extends AirtimeUpgrader { + protected function getSupportedVersions() { + return array ( + '2.5.5' + ); + } + + protected function getNewVersion() { + return '2.5.9'; + } + + public function upgrade($dir = __DIR__) { + Cache::clear(); + assert($this->checkIfUpgradeSupported()); + + $newVersion = $this->getNewVersion(); + + try { + $this->toggleMaintenanceScreen(true); + Cache::clear(); + + // Begin upgrade + $airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf"; + $values = parse_ini_file($airtimeConf, true); + + $username = $values['database']['dbuser']; + $password = $values['database']['dbpass']; + $host = $values['database']['host']; + $database = $values['database']['dbname']; + + passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_" + .$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\""); + + Application_Model_Preference::SetAirtimeVersion($newVersion); + Cache::clear(); + + $this->toggleMaintenanceScreen(false); + } catch(Exception $e) { + $this->toggleMaintenanceScreen(false); + throw $e; + } + } +}