0

I'm trying to run Doctrine migrations in Symfony3.4 project however I stuck for a couple of days now. Does anyone faced the same issue? How to make this work? Thanks in advance!

php bin/console doctrine:migrations:migrate Version20180909015642

19:03:19 ERROR     [console] Error thrown while running command 
"doctrine:migrations:migrate". Message: "An exception occured in 
driver: SQLSTATE[HY000] [2002] No such file or directory" ["exception" 
=> Doctrine\DBAL\Exception\ConnectionException { …},"command" => 
"doctrine:migrations:migrate","message" => "An exception occured in 
driver: SQLSTATE[HY000] [2002] No such file or directory"] []

In AbstractMySQLDriver.php line 103:

  An exception occured in driver: SQLSTATE[HY000] [2002] No such file 
or directory  

In PDOConnection.php line 47:

  SQLSTATE[HY000] [2002] No such file or directory  

In PDOConnection.php line 43:

  SQLSTATE[HY000] [2002] No such file or directory  

Bundle is registered in AppKernel.php

new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),

In config.yml

doctrine_migrations:
    dir_name: "%kernel.root_dir%/DoctrineMigrations"
    namespace: Application\Migrations
    table_name: doctrine_migration_versions
    name: Application_Migrations_Default

app/DoctrineMigrations/Version20180909015642.php

<?php
declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
class Version20180909015642 extends AbstractMigration
{


    /**
     * @param Schema $schema
     */
    public function up(Schema $schema)
    {
        //...
    }

    /**
     * @param Schema $schema
     */
    public function down(Schema $schema)
    {
        //...
    }
}
eazybob
  • 109
  • 2
  • 10

1 Answers1

0

The console commands have help options -h which are very helpful.

 php bin/console doctrine:migrations -h

Have said that, for migrating up to specific migration file you should use timestamp of the final migration file like bellow

 php bin/console doctrine:migrations:migrate 20180909015642

For executing specific migration file though, the execute command should be used; like following

php bin/console doctrine:migrations:execute 20180909015642 --up

Get help on specific command to see full explanation and examples

php bin/console doctrine:migrations:execute -h

php bin/console doctrine:migrations:migrate -h
Navid
  • 894
  • 7
  • 14