AzuraCast/src/Entity/Migration/Version20180425050351.php

50 lines
1.9 KiB
PHP
Raw Normal View History

2019-09-04 18:00:51 +00:00
<?php declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180425050351 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
// 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\'.');
$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,
'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
*/
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');
}
}