]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Use actual database name
authorJeremy Benoist <jeremy.benoist@gmail.com>
Tue, 13 Dec 2016 09:31:53 +0000 (10:31 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 19 Dec 2016 09:35:25 +0000 (10:35 +0100)
We can't retrieve the environment within the migration.
And when we ran migration on Travis, database name isn't `database_name` but `test_database_name`.
Retrieve the database name from the connection is more accurate

app/DoctrineMigrations/Version20161022134138.php

index 3ac8cc5b4a520f94417b131bdbd7f5bd01f064e3..22469f632ffe867fa317757c0a4a40244dd54aaa 100644 (file)
@@ -31,7 +31,7 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
     {
         $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
 
-        $this->addSql('ALTER DATABASE '.$this->container->getParameter('database_name').' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
+        $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
 
         // convert field length for utf8mb4
         // http://stackoverflow.com/a/31474509/569101
@@ -62,7 +62,7 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
     {
         $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
 
-        $this->addSql('ALTER DATABASE '.$this->container->getParameter('database_name').' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
+        $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
 
         $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;');