2016-10-22 14:01:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Application\Migrations;
|
|
|
|
|
2023-08-05 19:35:09 +02:00
|
|
|
use Doctrine\DBAL\Platforms\MySQLPlatform;
|
2016-10-22 14:01:58 +02:00
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
2024-02-19 01:30:12 +01:00
|
|
|
use Wallabag\Doctrine\WallabagMigration;
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2017-01-13 14:51:37 +01:00
|
|
|
/**
|
2017-04-13 12:57:31 +02:00
|
|
|
* Converted database to utf8mb4 encoding (for MySQL only).
|
2017-01-13 14:51:37 +01:00
|
|
|
*/
|
2018-06-14 13:43:09 +02:00
|
|
|
class Version20161022134138 extends WallabagMigration
|
2016-10-22 14:01:58 +02:00
|
|
|
{
|
2022-12-14 14:36:29 +01:00
|
|
|
public function up(Schema $schema): void
|
2016-10-22 14:01:58 +02:00
|
|
|
{
|
2024-02-18 23:47:34 +01:00
|
|
|
if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) {
|
|
|
|
$this->write('This migration only apply to MySQL');
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2018-06-14 13:43:09 +02:00
|
|
|
$this->addSql('ALTER DATABASE `' . $this->connection->getParams()['dbname'] . '` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2016-12-12 11:01:54 +01:00
|
|
|
// convert field length for utf8mb4
|
|
|
|
// http://stackoverflow.com/a/31474509/569101
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE salt salt VARCHAR(180) NOT NULL;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE password password VARCHAR(180) NOT NULL;');
|
2016-12-12 11:01:54 +01:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `text` `text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `quote` `quote` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `title` `title` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `content` `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE `name` `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
}
|
|
|
|
|
2022-12-14 14:36:29 +01:00
|
|
|
public function down(Schema $schema): void
|
2016-10-22 14:01:58 +02:00
|
|
|
{
|
2024-02-18 23:47:34 +01:00
|
|
|
if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) {
|
|
|
|
$this->write('This migration only apply to MySQL');
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2018-06-14 13:43:09 +02:00
|
|
|
$this->addSql('ALTER DATABASE `' . $this->connection->getParams()['dbname'] . '` CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `text` `text` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `quote` `quote` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `title` `title` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `content` `content` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
2016-10-22 14:01:58 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
|
|
|
}
|
2016-10-22 14:01:58 +02:00
|
|
|
}
|