--- src/bundle/Command/MigrateFlexWorkflowCommand.php
+++ src/bundle/Command/MigrateFlexWorkflowCommand.php
@@ -11,6 +11,7 @@ namespace EzSystems\EzPlatformWorkflowBundle\Command;
 use Doctrine\DBAL\Connection;
 use Doctrine\DBAL\FetchMode;
 use Doctrine\DBAL\ParameterType;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Helper\ProgressBar;
 use Symfony\Component\Console\Input\InputInterface;
@@ -47,7 +48,7 @@ final class MigrateFlexWorkflowCommand extends Command
     private $gateway;
 
     /** @var \Doctrine\DBAL\Platforms\AbstractPlatform */
-    private $databasePlatform;
+    private $databasePlatform = null;
 
     /**
      * @throws \Doctrine\DBAL\DBALException
@@ -59,8 +60,6 @@ final class MigrateFlexWorkflowCommand extends Command
         $this->connection = $connection;
         $this->gateway = $gateway;
 
-        $this->databasePlatform = $connection->getDatabasePlatform();
-
         parent::__construct('ezplatform:migrate:flex-workflow');
     }
 
@@ -209,7 +208,7 @@ final class MigrateFlexWorkflowCommand extends Command
         $query = $this->connection->createQueryBuilder();
         $expr = $query->expr();
         $query
-            ->select($this->databasePlatform->getCountExpression('fw.id'))
+            ->select($this->getDatabasePlatform()->getCountExpression('fw.id'))
             ->from(self::FLEXWORKFLOW_TABLE, 'fw')
             ->innerJoin(
                 'fw',
@@ -322,4 +321,12 @@ final class MigrateFlexWorkflowCommand extends Command
 
         return $query->execute();
     }
+
+    private function getDatabasePlatform(): AbstractPlatform {
+        $this->databasePlatform = !is_null($this->databasePlatform) ? 
+            $this->databasePlatform :
+            $this->connection->getDatabasePlatform();
+
+        return $this->databasePlatform;
+    }
 }
