CC-2279: Upgrade script for converting stor directory to new format
-testing fixes
This commit is contained in:
parent
a2b7bd2a0b
commit
62b6d020bb
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
//CC-2279 Upgrade script for converting stor directory to new format
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
//CC-2279 Upgrade script for creating the cc_music_dirs table.
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration,
|
||||
Doctrine\DBAL\Schema\Schema;
|
||||
|
@ -21,15 +19,9 @@ class Version20110629143017 extends AbstractMigration
|
|||
$cc_music_dirs->setPrimaryKey(array('id'));
|
||||
|
||||
//end create cc_music_dirs table
|
||||
|
||||
|
||||
//start cc_files modifications
|
||||
$cc_files = $schema->getTable('cc_files');
|
||||
$cc_files->addColumn('directory', 'integer', array('default'=> -1));
|
||||
|
||||
//$cc_files->addNamedForeignKeyConstraint('cc_music_dirs_folder_fkey', $cc_music_dirs, array('directory'), array('id'), array('onDelete' => 'CASCADE'));
|
||||
//end cc_files modifications
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
/*
|
||||
update cc_files table to include to "directory" column as well as add foreign key relation to
|
||||
cc_music_dirs table.
|
||||
*/
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration,
|
||||
Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
class Version20110711161043 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
|
||||
//CREATE the default value of "/srv/airtime/stor", this can be updated later in the upgrade script.
|
||||
$this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('stor', '/srv/airtime/stor');");
|
||||
|
||||
$this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('upgrade', '');");
|
||||
}
|
||||
|
||||
public function postUp(Schema $schema){
|
||||
$cc_music_dirs = $schema->getTable('cc_music_dirs');
|
||||
|
||||
//start cc_files modifications
|
||||
$cc_files = $schema->getTable('cc_files');
|
||||
$cc_files->addColumn('directory', 'integer', array('default'=> 2));
|
||||
|
||||
$cc_files->addNamedForeignKeyConstraint('cc_music_dirs_folder_fkey', $cc_music_dirs, array('directory'), array('id'), array('onDelete' => 'CASCADE'));
|
||||
//end cc_files modifications
|
||||
}
|
||||
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -415,7 +415,7 @@ AirtimeInstall::CreateCronFile();
|
|||
//Handle Database Changes.
|
||||
$stor_dir = realpath($values['general']['base_files_dir']."/stor")."/";
|
||||
echo "* Inserting stor directory location $stor_dir into music_dirs table".PHP_EOL;
|
||||
$sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('$stor_dir', 'stor')";
|
||||
$sql = "UPDATE cc_music_dirs SET directory='$stor_dir' WHERE type='stor'";
|
||||
echo $sql.PHP_EOL;
|
||||
execSqlQuery($sql);
|
||||
|
||||
|
@ -428,19 +428,20 @@ $rows = execSqlQuery($sql);
|
|||
//old database had a "fullpath" column that stored the absolute path of each track. We have to
|
||||
//change it so that the "fullpath" column has path relative to the "directory" column.
|
||||
|
||||
echo "Creating media-monitor log file";
|
||||
mkdir("/var/log/airtime/media-monitor/", 755, true);
|
||||
touch("/var/log/airtime/media-monitor/media-monitor.log");
|
||||
|
||||
//create media monitor config:
|
||||
if (!copy(__DIR__."/../../../python_apps/media-monitor/media-monitor.cfg", CONF_FILE_MEDIAMONITOR)){
|
||||
echo "Could not copy media-monitor.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "Reorganizing files in stor directory";
|
||||
$mediaMonitorUpgradePath = realpath(__DIR__."/../../../python_apps/media-monitor/media-monitor-upgrade.py");
|
||||
exec("su -c \"python $mediaMonitorUpgradePath\"", $output);
|
||||
|
||||
echo $output[0];
|
||||
print_r($output);
|
||||
|
||||
$oldAndNewFileNames = json_decode($output[0]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue