Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
-
Command " |
BetaWas this translation helpful?Give feedback.
All reactions
https://github.com/doctrine/dbal/blob/3.4.4/UPGRADE.md#bc-break-removed-dbalimport-cli-command
DBAL 3.x dropped support for it as noted in the upgrade guide. The corresponding command in the DoctrineBundle is deprecated and is only registered when DBAL 2.x is detected.
Replies: 1 comment 7 replies
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
https://github.com/doctrine/dbal/blob/3.4.4/UPGRADE.md#bc-break-removed-dbalimport-cli-command DBAL 3.x dropped support for it as noted in the upgrade guide. The corresponding command in the DoctrineBundle is deprecated and is only registered when DBAL 2.x is detected. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
you can also do :
|
BetaWas this translation helpful?Give feedback.
All reactions
-
@jcrombez Unfortunately, that yields the error |
BetaWas this translation helpful?Give feedback.
All reactions
👍 3
-
Has anyone found a working fix? I also ran into this issue and nothing seems to replace doctrine:database:import appropriately. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Well, the replacement is given by the Doctrine DBAL upgrade file (note that I edited the answer to give a link pointing to a tag rather than a removed branch so that the link works) |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
In my case the database is somewhere else so I do not have access to a database client. Hence I implemented a simple script: <?phpdeclare(strict_types=1);namespaceApp\Command;useDoctrine\Bundle\DoctrineBundle\Command\DoctrineCommand;useDoctrine\DBAL\Connection;useSymfony\Component\Console\Input\InputArgument;useSymfony\Component\Console\Input\InputInterface;useSymfony\Component\Console\Input\InputOption;useSymfony\Component\Console\Output\OutputInterface;/** * Task for executing arbitrary SQL that can come from a file or directly from the command line. * * From https://github.com/doctrine/dbal/blob/c2b8e6e82732a64ecde1cddf9e1e06cb8556e3d8/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php * Connection retrieval from https://github.com/doctrine/DoctrineBundle/blob/84f166beb72711b40419a9c0c62aa88729273d51/src/Command/CreateDatabaseDoctrineCommand.php */class SqlImportCommandextends DoctrineCommand{/** * {@inheritdoc} */protectedfunctionconfigure() {$this ->setName('app:sql:import') ->setDescription('Import SQL file(s) directly to Database.') ->addOption('connection','c', InputOption::VALUE_OPTIONAL,'The connection to use for this command') ->addArgument('file', InputArgument::REQUIRED | InputArgument::IS_ARRAY,'File path(s) of SQL to be executed.') ->setHelp('Import SQL file(s) directly to Database.'); }/** * {@inheritdoc} */protectedfunctionexecute(InputInterface$input,OutputInterface$output) {$connectionName =$input->getOption('connection');assert($connectionName ===null ||is_string($connectionName));$fileNames =$input->getArgument('file');$connection =$this->getDoctrine()->getConnection($connectionName);assert($connectioninstanceof Connection);foreach ($fileNamesas$fileName) {$filePath =realpath($fileName);$output->write(sprintf("Processing file '<info>%s</info>'...",$filePath));$sql =file_get_contents($filePath);$connection->prepare($sql)->executeStatement(); }return0; }} This is using the internal |
BetaWas this translation helpful?Give feedback.