(IMPORTANT: If coming from an older version of AzuraCast, update to this version FIRST to ensure your database matches the pre-migration setup. Future updates will be versioned with Doctrine's migrations system.) Implement Doctrine migrations as a replacement for the not-recommended-in-production Doctrine ORM schema manager update tool.

This commit is contained in:
Buster Silver 2016-09-23 18:40:53 -05:00
parent 39620ae482
commit 85461060c1
7 changed files with 463 additions and 8 deletions

View File

View File

@ -12,6 +12,9 @@
"zendframework/zend-paginator": "^2.7",
"zendframework/zend-config": "^2.6",
"doctrine/migrations": "^1.4",
"jdorn/sql-formatter": "^1.2",
"guzzlehttp/guzzle": ">6.0",
"electrolinux/phpquery": "0.9.6",
"nette/mail": "2.3.0",

394
composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "9b6654783a7b39fee4529689dd0dfdfe",
"content-hash": "10bba14067a3149c723f355568f74d9f",
"hash": "38472efa8a18840736fda28d8a90fad2",
"content-hash": "86a415f953295a4305f61cbd03d79446",
"packages": [
{
"name": "container-interop/container-interop",
@ -557,6 +557,79 @@
],
"time": "2014-09-09 13:34:57"
},
{
"name": "doctrine/migrations",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/migrations.git",
"reference": "0d0ff5da10c5d30846da32060bd9e357abf70a05"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/migrations/zipball/0d0ff5da10c5d30846da32060bd9e357abf70a05",
"reference": "0d0ff5da10c5d30846da32060bd9e357abf70a05",
"shasum": ""
},
"require": {
"doctrine/dbal": "~2.2",
"ocramius/proxy-manager": "^1.0|^2.0",
"php": "^5.5|^7.0",
"symfony/console": "~2.3|~3.0",
"symfony/yaml": "~2.3|~3.0"
},
"require-dev": {
"doctrine/coding-standard": "dev-master",
"doctrine/orm": "2.*",
"jdorn/sql-formatter": "~1.1",
"johnkary/phpunit-speedtrap": "~1.0@dev",
"mockery/mockery": "^0.9.4",
"phpunit/phpunit": "~4.7",
"satooshi/php-coveralls": "0.6.*"
},
"suggest": {
"jdorn/sql-formatter": "Allows to generate formatted SQL with the diff command."
},
"bin": [
"bin/doctrine-migrations"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "v1.5.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\DBAL\\Migrations\\": "lib/Doctrine/DBAL/Migrations"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
],
"authors": [
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Michael Simonson",
"email": "contact@mikesimonson.com"
}
],
"description": "Database Schema migrations using Doctrine DBAL",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"database",
"migrations"
],
"time": "2016-03-14 12:29:11"
},
{
"name": "doctrine/orm",
"version": "v2.5.5",
@ -1001,6 +1074,56 @@
],
"time": "2016-03-02 13:13:30"
},
{
"name": "jdorn/sql-formatter",
"version": "v1.2.17",
"source": {
"type": "git",
"url": "https://github.com/jdorn/sql-formatter.git",
"reference": "64990d96e0959dff8e059dfcdc1af130728d92bc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jdorn/sql-formatter/zipball/64990d96e0959dff8e059dfcdc1af130728d92bc",
"reference": "64990d96e0959dff8e059dfcdc1af130728d92bc",
"shasum": ""
},
"require": {
"php": ">=5.2.4"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
},
"autoload": {
"classmap": [
"lib"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jeremy Dorn",
"email": "jeremy@jeremydorn.com",
"homepage": "http://jeremydorn.com/"
}
],
"description": "a PHP SQL highlighting library",
"homepage": "https://github.com/jdorn/sql-formatter/",
"keywords": [
"highlight",
"sql"
],
"time": "2014-01-12 16:20:24"
},
{
"name": "league/plates",
"version": "3.1.1",
@ -1256,6 +1379,117 @@
],
"time": "2016-06-12 19:08:51"
},
{
"name": "ocramius/package-versions",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/Ocramius/PackageVersions.git",
"reference": "4b2bfc8128db95b533303942b0d5b332bffa07c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/4b2bfc8128db95b533303942b0d5b332bffa07c6",
"reference": "4b2bfc8128db95b533303942b0d5b332bffa07c6",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0",
"php": "~7.0"
},
"require-dev": {
"composer/composer": "^1.2.0",
"phpunit/phpunit": "^5.4.7"
},
"type": "composer-plugin",
"extra": {
"class": "PackageVersions\\Installer",
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"PackageVersions\\": "src/PackageVersions"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com"
}
],
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"time": "2016-07-25 07:13:56"
},
{
"name": "ocramius/proxy-manager",
"version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/Ocramius/ProxyManager.git",
"reference": "51c7fdd99dba53808aaab21b34f7a55b302c160c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Ocramius/ProxyManager/zipball/51c7fdd99dba53808aaab21b34f7a55b302c160c",
"reference": "51c7fdd99dba53808aaab21b34f7a55b302c160c",
"shasum": ""
},
"require": {
"ocramius/package-versions": "^1.0",
"php": "7.0.0 - 7.0.5 || ^7.0.7",
"zendframework/zend-code": "3.0.0 - 3.0.2 || ^3.0.4"
},
"require-dev": {
"couscous/couscous": "^1.4.0",
"ext-phar": "*",
"phpunit/phpunit": "^5.3.4",
"squizlabs/php_codesniffer": "^2.6.0"
},
"suggest": {
"ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects",
"zendframework/zend-json": "To have the JsonRpc adapter (Remote Object feature)",
"zendframework/zend-soap": "To have the Soap adapter (Remote Object feature)",
"zendframework/zend-xmlrpc": "To have the XmlRpc adapter (Remote Object feature)"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-0": {
"ProxyManager\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "http://ocramius.github.io/"
}
],
"description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies",
"homepage": "https://github.com/Ocramius/ProxyManager",
"keywords": [
"aop",
"lazy loading",
"proxy",
"proxy pattern",
"service proxies"
],
"time": "2016-07-01 12:11:54"
},
{
"name": "pimple/pimple",
"version": "v3.0.2",
@ -1647,6 +1881,55 @@
],
"time": "2016-05-18 14:26:46"
},
{
"name": "symfony/yaml",
"version": "v3.1.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/f291ed25eb1435bddbe8a96caaef16469c2a092d",
"reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2016-09-02 02:12:52"
},
{
"name": "tedivm/stash",
"version": "v0.14.1",
@ -1707,6 +1990,59 @@
],
"time": "2016-02-10 22:23:16"
},
{
"name": "zendframework/zend-code",
"version": "3.0.4",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-code.git",
"reference": "c5272131d3acb0f470a2462ed088fca3b6ba61c2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-code/zipball/c5272131d3acb0f470a2462ed088fca3b6ba61c2",
"reference": "c5272131d3acb0f470a2462ed088fca3b6ba61c2",
"shasum": ""
},
"require": {
"php": "^5.5 || 7.0.0 - 7.0.4 || ^7.0.6",
"zendframework/zend-eventmanager": "^2.6 || ^3.0"
},
"require-dev": {
"doctrine/annotations": "~1.0",
"ext-phar": "*",
"phpunit/phpunit": "^4.8.21",
"squizlabs/php_codesniffer": "^2.5",
"zendframework/zend-stdlib": "^2.7 || ^3.0"
},
"suggest": {
"doctrine/annotations": "Doctrine\\Common\\Annotations >=1.0 for annotation features",
"zendframework/zend-stdlib": "Zend\\Stdlib component"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev",
"dev-develop": "3.1-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\Code\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "provides facilities to generate arbitrary code using an object oriented interface",
"homepage": "https://github.com/zendframework/zend-code",
"keywords": [
"code",
"zf2"
],
"time": "2016-06-30 22:35:27"
},
{
"name": "zendframework/zend-config",
"version": "2.6.0",
@ -1763,6 +2099,60 @@
],
"time": "2016-02-04 23:01:10"
},
{
"name": "zendframework/zend-eventmanager",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-eventmanager.git",
"reference": "5c80bdee0e952be112dcec0968bad770082c3a6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/5c80bdee0e952be112dcec0968bad770082c3a6e",
"reference": "5c80bdee0e952be112dcec0968bad770082c3a6e",
"shasum": ""
},
"require": {
"php": "^5.5 || ^7.0"
},
"require-dev": {
"athletic/athletic": "^0.1",
"container-interop/container-interop": "^1.1.0",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "^2.0",
"zendframework/zend-stdlib": "^2.7.3 || ^3.0"
},
"suggest": {
"container-interop/container-interop": "^1.1.0, to use the lazy listeners feature",
"zendframework/zend-stdlib": "^2.7.3 || ^3.0, to use the FilterChain feature"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev",
"dev-develop": "3.1-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\EventManager\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Trigger and listen to events within a PHP application",
"homepage": "https://github.com/zendframework/zend-eventmanager",
"keywords": [
"event",
"eventmanager",
"events",
"zf2"
],
"time": "2016-02-18 20:53:00"
},
{
"name": "zendframework/zend-paginator",
"version": "2.7.0",

View File

@ -5,8 +5,12 @@
shell: php {{ util_base }}/cli.php cache:clear
when: azuracast_db_created.changed
- name: Install Doctrine Database
- name: Install Initial Database
mysql_db: state=import name="azuracast" target="{{ util_base }}/azuracast_db.sql"
when: azuracast_db_created.changed
- name: Apply All DB Migrations
become: true
become_user: azuracast
shell: php {{ util_base }}/cli.php orm:schema-tool:create
shell: php {{ util_base }}/cli.php migrations:migrate --no-interaction
when: azuracast_db_created.changed

View File

@ -35,10 +35,10 @@
become_user: azuracast
shell: php {{ util_base }}/cli.php cache:clear
- name: Update Doctrine Database
- name: Update Database
become: true
become_user: azuracast
shell: php {{ util_base }}/cli.php orm:schema-tool:update --force --complete
shell: php {{ util_base }}/cli.php migrations:migrate --no-interaction
- name: Restart Radio Stations
become: true

34
util/azuracast_db.sql Normal file
View File

@ -0,0 +1,34 @@
CREATE TABLE action (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE analytics (id INT AUTO_INCREMENT NOT NULL, station_id INT DEFAULT NULL, type VARCHAR(15) NOT NULL, timestamp INT NOT NULL, number_min INT NOT NULL, number_max INT NOT NULL, number_avg INT NOT NULL, INDEX IDX_EAC2E68821BDB235 (station_id), INDEX search_idx (type, timestamp), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE api_keys (id VARCHAR(50) NOT NULL, owner VARCHAR(150) DEFAULT NULL, calls_made INT NOT NULL, created INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE role (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE role_has_action (role_id INT NOT NULL, action_id INT NOT NULL, INDEX IDX_E4DAF125D60322AC (role_id), INDEX IDX_E4DAF1259D32F035 (action_id), PRIMARY KEY(role_id, action_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE settings (setting_key VARCHAR(64) NOT NULL, setting_value LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', PRIMARY KEY(setting_key)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE songs (id VARCHAR(50) NOT NULL, text VARCHAR(150) DEFAULT NULL, artist VARCHAR(150) DEFAULT NULL, title VARCHAR(150) DEFAULT NULL, created INT NOT NULL, play_count INT NOT NULL, last_played INT NOT NULL, INDEX search_idx (text, artist, title), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE song_history (id INT AUTO_INCREMENT NOT NULL, song_id VARCHAR(50) NOT NULL, station_id INT NOT NULL, timestamp_start INT NOT NULL, listeners_start INT DEFAULT NULL, timestamp_end INT NOT NULL, listeners_end SMALLINT DEFAULT NULL, delta_total SMALLINT NOT NULL, delta_positive SMALLINT NOT NULL, delta_negative SMALLINT NOT NULL, delta_points LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', INDEX IDX_2AD16164A0BDB2F3 (song_id), INDEX IDX_2AD1616421BDB235 (station_id), INDEX sort_idx (timestamp_start), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE station (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100) DEFAULT NULL, frontend_type VARCHAR(100) DEFAULT NULL, frontend_config LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', backend_type VARCHAR(100) DEFAULT NULL, backend_config LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', description LONGTEXT DEFAULT NULL, radio_base_dir VARCHAR(255) DEFAULT NULL, nowplaying_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', automation_settings LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', automation_timestamp INT DEFAULT NULL, enable_requests TINYINT(1) NOT NULL, request_delay INT DEFAULT NULL, enable_streamers TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE station_media (id INT AUTO_INCREMENT NOT NULL, station_id INT NOT NULL, song_id VARCHAR(50) DEFAULT NULL, title VARCHAR(200) DEFAULT NULL, artist VARCHAR(200) DEFAULT NULL, album VARCHAR(200) DEFAULT NULL, length SMALLINT NOT NULL, length_text VARCHAR(10) DEFAULT NULL, path VARCHAR(255) DEFAULT NULL, mtime INT DEFAULT NULL, INDEX IDX_32AADE3A21BDB235 (station_id), INDEX IDX_32AADE3AA0BDB2F3 (song_id), INDEX search_idx (title, artist, album), UNIQUE INDEX path_unique_idx (path), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE station_playlist_has_media (media_id INT NOT NULL, playlists_id INT NOT NULL, INDEX IDX_668E6486EA9FDD75 (media_id), INDEX IDX_668E64869F70CF56 (playlists_id), PRIMARY KEY(media_id, playlists_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE station_playlists (id INT AUTO_INCREMENT NOT NULL, station_id INT NOT NULL, name VARCHAR(200) NOT NULL, type VARCHAR(50) NOT NULL, is_enabled TINYINT(1) NOT NULL, play_per_songs SMALLINT NOT NULL, play_per_minutes SMALLINT NOT NULL, schedule_start_time SMALLINT NOT NULL, schedule_end_time SMALLINT NOT NULL, play_once_time SMALLINT NOT NULL, weight SMALLINT NOT NULL, include_in_automation TINYINT(1) NOT NULL, INDEX IDX_DC827F7421BDB235 (station_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE station_requests (id INT AUTO_INCREMENT NOT NULL, station_id INT NOT NULL, track_id INT NOT NULL, timestamp INT NOT NULL, played_at INT NOT NULL, ip VARCHAR(40) NOT NULL, INDEX IDX_F71F0C0721BDB235 (station_id), INDEX IDX_F71F0C075ED23C43 (track_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE station_streamers (id INT AUTO_INCREMENT NOT NULL, station_id INT NOT NULL, streamer_username VARCHAR(50) NOT NULL, streamer_password VARCHAR(50) NOT NULL, comments LONGTEXT DEFAULT NULL, is_active TINYINT(1) NOT NULL, INDEX IDX_5170063E21BDB235 (station_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE users (uid INT AUTO_INCREMENT NOT NULL, email VARCHAR(100) DEFAULT NULL, auth_password VARCHAR(255) DEFAULT NULL, auth_last_login_time INT DEFAULT NULL, auth_recovery_code VARCHAR(50) DEFAULT NULL, name VARCHAR(100) DEFAULT NULL, gender VARCHAR(1) DEFAULT NULL, customization LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', PRIMARY KEY(uid)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE user_has_role (user_id INT NOT NULL, role_id INT NOT NULL, INDEX IDX_EAB8B535A76ED395 (user_id), INDEX IDX_EAB8B535D60322AC (role_id), PRIMARY KEY(user_id, role_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE user_manages_station (user_id INT NOT NULL, station_id INT NOT NULL, INDEX IDX_2453B56BA76ED395 (user_id), INDEX IDX_2453B56B21BDB235 (station_id), PRIMARY KEY(user_id, station_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
ALTER TABLE analytics ADD CONSTRAINT FK_EAC2E68821BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE;
ALTER TABLE role_has_action ADD CONSTRAINT FK_E4DAF125D60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE;
ALTER TABLE role_has_action ADD CONSTRAINT FK_E4DAF1259D32F035 FOREIGN KEY (action_id) REFERENCES action (id) ON DELETE CASCADE;
ALTER TABLE song_history ADD CONSTRAINT FK_2AD16164A0BDB2F3 FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE CASCADE;
ALTER TABLE song_history ADD CONSTRAINT FK_2AD1616421BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE;
ALTER TABLE station_media ADD CONSTRAINT FK_32AADE3A21BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE;
ALTER TABLE station_media ADD CONSTRAINT FK_32AADE3AA0BDB2F3 FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE SET NULL;
ALTER TABLE station_playlist_has_media ADD CONSTRAINT FK_668E6486EA9FDD75 FOREIGN KEY (media_id) REFERENCES station_media (id) ON DELETE CASCADE;
ALTER TABLE station_playlist_has_media ADD CONSTRAINT FK_668E64869F70CF56 FOREIGN KEY (playlists_id) REFERENCES station_playlists (id) ON DELETE CASCADE;
ALTER TABLE station_playlists ADD CONSTRAINT FK_DC827F7421BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE;
ALTER TABLE station_requests ADD CONSTRAINT FK_F71F0C0721BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE;
ALTER TABLE station_requests ADD CONSTRAINT FK_F71F0C075ED23C43 FOREIGN KEY (track_id) REFERENCES station_media (id) ON DELETE CASCADE;
ALTER TABLE station_streamers ADD CONSTRAINT FK_5170063E21BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE;
ALTER TABLE user_has_role ADD CONSTRAINT FK_EAB8B535A76ED395 FOREIGN KEY (user_id) REFERENCES users (uid) ON DELETE CASCADE;
ALTER TABLE user_has_role ADD CONSTRAINT FK_EAB8B535D60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE;
ALTER TABLE user_manages_station ADD CONSTRAINT FK_2453B56BA76ED395 FOREIGN KEY (user_id) REFERENCES users (uid) ON DELETE CASCADE;
ALTER TABLE user_manages_station ADD CONSTRAINT FK_2453B56B21BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE;

View File

@ -4,10 +4,13 @@ ini_set('display_errors', 1);
require dirname(__FILE__).'/../app/bootstrap.php';
$em = $di->get('em');
$em = $di['em'];
$db = $em->getConnection();
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($db),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em),
'dialog' => new \Symfony\Component\Console\Helper\QuestionHelper(),
));
$cli = new \Symfony\Component\Console\Application($config->application->name.' Command Line Tools', \App\Version::getVersion());
@ -16,6 +19,27 @@ $cli->setHelperSet($helperSet);
\Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli);
// Migrations commands
$migrate_config = new \Doctrine\DBAL\Migrations\Configuration\Configuration($db);
$migrate_config->setMigrationsTableName('app_migrations');
$migrate_config->setMigrationsDirectory(APP_INCLUDE_MODELS.'/Migration');
$migrate_config->setMigrationsNamespace('Migration');
$migration_commands = array(
new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand()
);
foreach($migration_commands as $cmd)
$cmd->setMigrationConfiguration($migrate_config);
$cli->addCommands($migration_commands);
// App-specific commands
$cli->addCommands(array(
new \App\Console\Command\ClearCache($di),
new \App\Console\Command\RestartRadio($di),