From 877787e5fe6a6545105616968939949b4db81347 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 28 Nov 2018 20:26:18 +0100 Subject: Fix utf8mb4 on vendor tables When creating the schema for test these tables use default length for string: 255. Which fail when using utf8mb4. > Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes Also move the `setKeepStaticConnections` in before and after class to avoid: > SAVEPOINT DOCTRINE2_SAVEPOINT_2 does not exist See https://github.com/dmaicher/doctrine-test-bundle#troubleshooting --- app/DoctrineMigrations/Version20180405182455.php | 21 ++--------- app/DoctrineMigrations/Version20181128203230.php | 45 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 app/DoctrineMigrations/Version20181128203230.php (limited to 'app/DoctrineMigrations') diff --git a/app/DoctrineMigrations/Version20180405182455.php b/app/DoctrineMigrations/Version20180405182455.php index 71879c0e..50fe97c7 100755 --- a/app/DoctrineMigrations/Version20180405182455.php +++ b/app/DoctrineMigrations/Version20180405182455.php @@ -2,26 +2,14 @@ namespace Application\Migrations; -use Doctrine\DBAL\Migrations\AbstractMigration; use Doctrine\DBAL\Schema\Schema; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Wallabag\CoreBundle\Doctrine\WallabagMigration; /** * Add archived_at column and set its value to updated_at for is_archived entries. */ -class Version20180405182455 extends AbstractMigration implements ContainerAwareInterface +class Version20180405182455 extends WallabagMigration { - /** - * @var ContainerInterface - */ - private $container; - - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } - /** * @param Schema $schema */ @@ -60,9 +48,4 @@ class Version20180405182455 extends AbstractMigration implements ContainerAwareI $entryTable->dropColumn('archived_at'); } - - private function getTable($tableName) - { - return $this->container->getParameter('database_table_prefix') . $tableName; - } } diff --git a/app/DoctrineMigrations/Version20181128203230.php b/app/DoctrineMigrations/Version20181128203230.php new file mode 100644 index 00000000..d1b09fc7 --- /dev/null +++ b/app/DoctrineMigrations/Version20181128203230.php @@ -0,0 +1,45 @@ +skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration can only be applied on \'mysql\'.'); + + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `token` `token` varchar(191) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `scope` `scope` varchar(191)'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `token` `token` varchar(191) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `scope` `scope` varchar(191)'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `token` `token` varchar(191) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `scope` `scope` varchar(191)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `name` `name` varchar(191)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `section` `section` varchar(191)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `value` `value` varchar(191)'); + } + + public function down(Schema $schema) + { + $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration can only be applied on \'mysql\'.'); + + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `token` `token` varchar(255) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `scope` `scope` varchar(255)'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `token` `token` varchar(255) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `scope` `scope` varchar(255)'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `token` `token` varchar(255) NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `scope` `scope` varchar(255)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `name` `name` varchar(255)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `section` `section` varchar(255)'); + $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `value` `value` varchar(255)'); + } +} -- cgit v1.2.3