akeneo / transporteo

Migration Tool for Akeneo PIM from 1.7 to 2.0
Other
8 stars 7 forks source link

Migration Remote to local (Docker) - Step 8 - Structure Migration: SQLSTATE[HY000] [2002] No such file or directory #62

Open jycamier opened 6 years ago

jycamier commented 6 years ago

With the official docker-compose, I have installed :

So after a minimal fresh install, I try to execute a migration between an Akeneo 1.7 EE and a Akeneo 2.0 EE.

 What is the name of the project you want to migrate? Please choose a name with snake_case and alphanumeric characters.  []:
 > test

 Where is located your source PIM? :
  [0] locally
  [1] on a remote server
 > 1

 What is the hostname of the source PIM? For instance, myhost.domain.com. Don't put the http or https prefix please. ;) []:
 > <my-host>

 What is the SSH port of the source PIM?  [22]:
 > 22039

 What is the SSH user you want to connect with to the source PIM?  []:
 > deploy

 What is the absolute path of the private SSH key able to connect to the source PIM?  []:
 > /home/docker/.ssh/id_rsa

 What is the absolute path of the source PIM composer.json on the server?  []:
 > /home/deploy/pim/akeneo/current/composer.json

 What is the base URI to request the API of the source PIM? []:
 > <my-URI>

 What is the client id to use to authenticate to the API of the source PIM? []:
 > <my-client-id>

 What is the secret associated to this client? []:
 > <my-secret>

 What is the username to use to authenticate to the API of the source PIM? []:
 > admin

 What is the password associated to this username? []:
 > admin

You want to migrate from an Enterprise edition with ORM storage.

 What is the absolute path of your local destination PIM?  []:
 > /srv/pim

 What is the base URI to request the API of the destination PIM? []:
 > http://httpd

Migrating files data...
Migrating structure data...

  [Akeneo\PimMigration\Domain\MigrationStep\s070_StructureMigration\StructureMigrationException (2002)]
  Error: Step 8 - Structure Migration: SQLSTATE[HY000] [2002] No such file or directory

Exception trace:
 () at /srv/pim/transporteo/src/Domain/MigrationStep/s070_StructureMigration/AttributeDataMigrator.php:51
 Akeneo\PimMigration\Domain\MigrationStep\s070_StructureMigration\AttributeDataMigrator->migrate() at /srv/pim/transporteo/src/Domain/MigrationStep/s070_StructureMigration/StructureMigrator.php:30
 Akeneo\PimMigration\Domain\MigrationStep\s070_StructureMigration\StructureMigrator->migrate() at /srv/pim/transporteo/src/Infrastructure/MigrationStep/S070FromDestinationPimFileDatabaseMigratedToDestinationPimStructureMigrated.php:52
 Akeneo\PimMigration\Infrastructure\MigrationStep\S070FromDestinationPimFileDatabaseMigratedToDestinationPimStructureMigrated->onDestinationPimStructureMigration() at n/a:n/a
 call_user_func() at /srv/pim/transporteo/vendor/symfony/event-dispatcher/EventDispatcher.php:212
 Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at /srv/pim/transporteo/vendor/symfony/event-dispatcher/EventDispatcher.php:44
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /srv/pim/transporteo/vendor/symfony/workflow/Workflow.php:256
 Symfony\Component\Workflow\Workflow->transition() at /srv/pim/transporteo/vendor/symfony/workflow/Workflow.php:137
 Symfony\Component\Workflow\Workflow->apply() at /srv/pim/transporteo/src/Infrastructure/MigrationToolStateMachine.php:94
 Akeneo\PimMigration\Infrastructure\MigrationToolStateMachine->start() at /srv/pim/transporteo/src/Infrastructure/UserInterface/Cli/MigrationTool.php:43
 Akeneo\PimMigration\Infrastructure\UserInterface\Cli\MigrationTool->execute() at /srv/pim/transporteo/vendor/symfony/console/Command/Command.php:264
 Symfony\Component\Console\Command\Command->run() at /srv/pim/transporteo/vendor/symfony/console/Application.php:887
 Symfony\Component\Console\Application->doRunCommand() at /srv/pim/transporteo/vendor/symfony/console/Application.php:223
 Symfony\Component\Console\Application->doRun() at /srv/pim/transporteo/vendor/symfony/console/Application.php:130
 Symfony\Component\Console\Application->run() at /srv/pim/transporteo/MigrationTool.php:17

  [PDOException (2002)]
  SQLSTATE[HY000] [2002] No such file or directory

Exception trace:
 () at /srv/pim/transporteo/src/Infrastructure/Cli/LocalMySqlQueryExecutor.php:54
 PDO->__construct() at /srv/pim/transporteo/src/Infrastructure/Cli/LocalMySqlQueryExecutor.php:54
 Akeneo\PimMigration\Infrastructure\Cli\LocalMySqlQueryExecutor->getConnection() at /srv/pim/transporteo/src/Infrastructure/Cli/LocalMySqlQueryExecutor.php:22
 Akeneo\PimMigration\Infrastructure\Cli\LocalMySqlQueryExecutor->execute() at /srv/pim/transporteo/src/Infrastructure/Cli/LocalConsole.php:48
 Akeneo\PimMigration\Infrastructure\Cli\LocalConsole->execute() at /srv/pim/transporteo/src/Domain/Command/ChainedConsole.php:23
 Akeneo\PimMigration\Domain\Command\ChainedConsole->execute() at /srv/pim/transporteo/src/Domain/MigrationStep/s070_StructureMigration/AttributeDataMigrator.php:44
 Akeneo\PimMigration\Domain\MigrationStep\s070_StructureMigration\AttributeDataMigrator->migrate() at /srv/pim/transporteo/src/Domain/MigrationStep/s070_StructureMigration/StructureMigrator.php:30
 Akeneo\PimMigration\Domain\MigrationStep\s070_StructureMigration\StructureMigrator->migrate() at /srv/pim/transporteo/src/Infrastructure/MigrationStep/S070FromDestinationPimFileDatabaseMigratedToDestinationPimStructureMigrated.php:52
 Akeneo\PimMigration\Infrastructure\MigrationStep\S070FromDestinationPimFileDatabaseMigratedToDestinationPimStructureMigrated->onDestinationPimStructureMigration() at n/a:n/a
 call_user_func() at /srv/pim/transporteo/vendor/symfony/event-dispatcher/EventDispatcher.php:212
 Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at /srv/pim/transporteo/vendor/symfony/event-dispatcher/EventDispatcher.php:44
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /srv/pim/transporteo/vendor/symfony/workflow/Workflow.php:256
 Symfony\Component\Workflow\Workflow->transition() at /srv/pim/transporteo/vendor/symfony/workflow/Workflow.php:137
 Symfony\Component\Workflow\Workflow->apply() at /srv/pim/transporteo/src/Infrastructure/MigrationToolStateMachine.php:94
 Akeneo\PimMigration\Infrastructure\MigrationToolStateMachine->start() at /srv/pim/transporteo/src/Infrastructure/UserInterface/Cli/MigrationTool.php:43
 Akeneo\PimMigration\Infrastructure\UserInterface\Cli\MigrationTool->execute() at /srv/pim/transporteo/vendor/symfony/console/Command/Command.php:264
 Symfony\Component\Console\Command\Command->run() at /srv/pim/transporteo/vendor/symfony/console/Application.php:887
 Symfony\Component\Console\Application->doRunCommand() at /srv/pim/transporteo/vendor/symfony/console/Application.php:223
 Symfony\Component\Console\Application->doRun() at /srv/pim/transporteo/vendor/symfony/console/Application.php:130
 Symfony\Component\Console\Application->run() at /srv/pim/transporteo/MigrationTool.php:17

Nevermind the exception, all my attributes are migrated.

anaelChardan commented 6 years ago

Hi @eheuje,

Thanks for raising this issue! Sorry, but we do not support Docker concerning the Destination PIM in Transporteo, we tried and we encountered some issues (folder differences between host and docker, mysql client on the host connecting to the docker one...) and we decided to not support it for now.

If you want, you can contributing by following this guideline and we will be happy to help you :-) https://github.com/akeneo/transporteo/blob/master/.github/CONTRIBUTING.md

Thanks!

Anaël

jycamier commented 6 years ago

I have just found the trouble.

Akeneo\PimMigration\Infrastructure\Cli\LocalMySqlQueryExecutor:45

    protected function getConnection(Pim $pim): \PDO
    {
        $dsn = sprintf(
            'mysql: host=%s;dbname=%s;port=%s',
            $pim->getMysqlHost(),
            $pim->getDatabaseName(),
            strval($pim->getMysqlPort())
        );

        $pdo = new \PDO(
            $dsn,
            $pim->getDatabaseUser(),
            $pim->getDatabasePassword()
        );

        $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

        return $pdo;
    }

If I remove the space in your connection string, it works...

    protected function getConnection(Pim $pim): \PDO
    {
        $dsn = sprintf(
            'mysql:host=%s;dbname=%s;port=%s',
            ...
        );
    }

Now, I have another one :

Migrating files data...
Migrating structure data...
Migrating families data...
Migrating system data...
Migrating jobs data...
Migrating groups data...
Migrating extra data...
Migrating reference data...
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Akeneo\PimMigration\Domain\Command\CommandResult::__construct() must be of the type integer, boolean given, called in /srv/pim/transporteo/src/Infrastructure/Cli/SshConsole.php on line 105 and defined in /srv/pim/transporteo/src/Domain/Command/CommandResult.php:21
Stack trace:
#0 /srv/pim/transporteo/src/Infrastructure/Cli/SshConsole.php(105): Akeneo\PimMigration\Domain\Command\CommandResult->__construct(false, 'Cannot load Zen...')
#1 /srv/pim/transporteo/src/Domain/Command/ChainedConsole.php(23): Akeneo\PimMigration\Infrastructure\Cli\SshConsole->execute('/home/deploy/pi...', Object(Akeneo\PimMigration\Domain\Pim\SourcePim))
#2 /srv/pim/transporteo/src/Domain/DataMigration/BundleConfigFetcher.php(32): Akeneo\PimMigration\Domain\Command\ChainedConsole->execute(Object(Akeneo\PimMigration\Domain\Command\SymfonyCommand), Object(Akeneo\PimMigration\Domain\Pim\SourcePim))
#3 /srv/pim/transporteo/src/Domain/MigrationStep/s130_ReferenceDataMigration/ReferenceDataMigrator.php in /srv/pim/transporteo/src/Domain/Command/CommandResult.php on line 21
anaelChardan commented 6 years ago

Thanks again ! :), I will have a deeper look into it and let you informed :)

tbrankaer commented 6 years ago

Any news about this error? I've this one also. The 'Argument 1 passed to Akeneo\PimMigration\Domain\Command\CommandResult::__construct() must be of the type integer, boolean given' error.

jycamier commented 6 years ago

I have done some dirty fixe. Look :

<?php

class CommandResult
{
    /** @var int */
    private $resultCode;

    /** @var mixed */
    private $output;

    public function __construct(int $resultCode, $output)
    {
        $this->resultCode = $resultCode;
        $this->output = $output;
    }

First argument must be an integer... In SshConsole.php

<?php

return new CommandResult($ssh->getExitStatus(), $results);

So the method getExitStatus must return an integer... But getExitStatus return sometimes boolean and sometime integer...

    /**
     * Returns the exit status of an SSH command or false.
     *
     * @return false|int
     * @access public
     */
    public function getExitStatus()
    {
        if (is_null($this->exit_status)) {
            return false;
        }
        return $this->exit_status;
    }

So, my dirty fix is :

In SshConsole.php

<?php

return new CommandResult((int) $ssh->getExitStatus(), $results);