2019-09-04 18:00:51 +00:00
|
|
|
<?php declare(strict_types=1);
|
2018-04-25 05:18:02 +00:00
|
|
|
|
2018-08-04 22:05:14 +00:00
|
|
|
namespace App\Entity\Migration;
|
2018-04-25 05:18:02 +00:00
|
|
|
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
2019-08-07 04:33:55 +00:00
|
|
|
use Doctrine\Migrations\AbstractMigration;
|
2018-04-25 05:18:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Auto-generated Migration: Please modify to your needs!
|
|
|
|
*/
|
2018-07-23 06:48:02 +00:00
|
|
|
final class Version20180425050351 extends AbstractMigration
|
2018-04-25 05:18:02 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param Schema $schema
|
|
|
|
*/
|
2019-09-10 23:35:07 +00:00
|
|
|
public function up(Schema $schema): void
|
2018-04-25 05:18:02 +00:00
|
|
|
{
|
|
|
|
// this up() migration is auto-generated, please modify it to your needs
|
2019-09-04 18:00:51 +00:00
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql',
|
|
|
|
'Migration can only be executed safely on \'mysql\'.');
|
2018-04-25 05:18:02 +00:00
|
|
|
|
|
|
|
$this->changeCharset('utf8mb4', 'utf8mb4_bin');
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function changeCharset($charset, $collate)
|
|
|
|
{
|
|
|
|
$this->addSql([
|
|
|
|
'ALTER TABLE `station_media` DROP FOREIGN KEY FK_32AADE3AA0BDB2F3',
|
|
|
|
'ALTER TABLE `song_history` DROP FOREIGN KEY FK_2AD16164A0BDB2F3',
|
2019-09-04 18:00:51 +00:00
|
|
|
'ALTER TABLE `station_media` CONVERT TO CHARACTER SET ' . $charset . ' COLLATE ' . $collate,
|
|
|
|
'ALTER TABLE `song_history` CONVERT TO CHARACTER SET ' . $charset . ' COLLATE ' . $collate,
|
|
|
|
'ALTER TABLE `songs` CONVERT TO CHARACTER SET ' . $charset . ' COLLATE ' . $collate,
|
2018-04-25 05:18:02 +00:00
|
|
|
'ALTER TABLE `song_history` ADD CONSTRAINT FK_2AD16164A0BDB2F3 FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE CASCADE',
|
|
|
|
'ALTER TABLE `station_media` ADD CONSTRAINT FK_32AADE3AA0BDB2F3 FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE SET NULL',
|
|
|
|
]);
|
|
|
|
}
|
2019-09-04 18:00:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Schema $schema
|
|
|
|
*/
|
2019-09-10 23:35:07 +00:00
|
|
|
public function down(Schema $schema): void
|
2019-09-04 18:00:51 +00:00
|
|
|
{
|
|
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql',
|
|
|
|
'Migration can only be executed safely on \'mysql\'.');
|
|
|
|
|
|
|
|
$this->changeCharset('utf8mb4', 'utf8mb4_unicode_ci');
|
|
|
|
}
|
2018-04-25 05:18:02 +00:00
|
|
|
}
|