CC-5781: Upgrade script for new storage quota implementation
Copied upgrade files to public folder. Seeing if we can execute the scripts with a URL
This commit is contained in:
parent
5948dc41da
commit
661ab7f647
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/* All functions other than start() should be marked as
|
||||||
|
* private.
|
||||||
|
*/
|
||||||
|
class AirtimeDatabaseUpgrade{
|
||||||
|
|
||||||
|
public static function start($p_dbValues){
|
||||||
|
echo "* Updating Database".PHP_EOL;
|
||||||
|
self::task0($p_dbValues);
|
||||||
|
echo " * Complete".PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function task0($p_dbValues){
|
||||||
|
|
||||||
|
$username = $p_dbValues['database']['dbuser'];
|
||||||
|
$password = $p_dbValues['database']['dbpass'];
|
||||||
|
$host = $p_dbValues['database']['host'];
|
||||||
|
$database = $p_dbValues['database']['dbname'];
|
||||||
|
$dir = __DIR__;
|
||||||
|
|
||||||
|
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/data/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class StorageQuotaUpgrade
|
||||||
|
{
|
||||||
|
public static function startUpgrade()
|
||||||
|
{
|
||||||
|
echo "* Updating storage usage for new quota tracking".PHP_EOL;
|
||||||
|
self::setStorageUsage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function setStorageUsage()
|
||||||
|
{
|
||||||
|
$musicDir = CcMusicDirsQuery::create()
|
||||||
|
->filterByType('stor')
|
||||||
|
->filterByExists(true)
|
||||||
|
->findOne();
|
||||||
|
$storPath = $musicDir->getDirectory();
|
||||||
|
|
||||||
|
$f = $storPath;
|
||||||
|
$io = popen('/usr/bin/du -bs ' . $f, 'r');
|
||||||
|
$size = fgets($io, 4096);
|
||||||
|
$size = substr($size, 0, strpos($size, "\t"));
|
||||||
|
pclose($io);
|
||||||
|
|
||||||
|
Application_Model_Preference::setDiskUsage($size);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Define path to application directory
|
||||||
|
defined('APPLICATION_PATH')
|
||||||
|
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
|
||||||
|
//include index.php so we can use propel classes
|
||||||
|
require_once APPLICATION_PATH.'/../public/index.php';
|
||||||
|
|
||||||
|
require_once 'DbUpgrade.php';
|
||||||
|
require_once 'StorageQuotaUpgrade.php';
|
||||||
|
|
||||||
|
$filename = "/etc/airtime/airtime.conf";
|
||||||
|
$values = parse_ini_file($filename, true);
|
||||||
|
|
||||||
|
AirtimeDatabaseUpgrade::start($values);
|
||||||
|
StorageQuotaUpgrade::startUpgrade();
|
|
@ -0,0 +1,6 @@
|
||||||
|
DELETE FROM cc_pref WHERE keystr = 'system_version';
|
||||||
|
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.5.3');
|
||||||
|
|
||||||
|
ALTER TABLE cc_files DROP COLUMN state;
|
||||||
|
ALTER TABLE cc_files ADD import_status integer default 1; -- Default is "pending"
|
||||||
|
UPDATE cc_files SET import_status=0; -- Existing files are already "imported"
|
Loading…
Reference in New Issue