-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[DoctrineBridge] Update AbstractSchemaListener to adjust more database params #54699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
DigitalOcean's mysql instance set the default config "sql_require_primary_key=true", it will cause `./bin/console doctrine:schema:update --dump-sql` throw an Exception:
```
In Connection.php line 33:
[PDOException (HY000)]
SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoi
d this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting.
Exception trace:
at /root/symfony-app/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:33
PDO->exec() at /root/symfony-app/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:33
Doctrine\DBAL\Driver\PDO\Connection->exec() at /root/symfony-app/vendor/doctrine/dbal/src/Driver/Middleware/AbstractConnectionMiddleware.php:46
Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware->exec() at /root/symfony-app/vendor/doctrine/dbal/src/Logging/Connection.php:50
Doctrine\DBAL\Logging\Connection->exec() at /root/symfony-app/vendor/doctrine/dbal/src/Driver/Middleware/AbstractConnectionMiddleware.php:46
Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware->exec() at /root/symfony-app/vendor/symfony/doctrine-bridge/Middleware/Debug/DBAL3/Connection.php:73
Symfony\Bridge\Doctrine\Middleware\Debug\DBAL3\Connection->exec() at /root/symfony-app/vendor/doctrine/dbal/src/Driver/Middleware/AbstractConnectionMiddleware.php:46
Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware->exec() at /root/symfony-app/bundles/DoctrineEnhanceBundle/src/Middleware/LogConnection.php:64
DoctrineEnhanceBundle\Middleware\LogConnection->exec() at /root/symfony-app/vendor/doctrine/dbal/src/Connection.php:1206
Doctrine\DBAL\Connection->executeStatement() at /root/symfony-app/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:1617
Doctrine\DBAL\Schema\AbstractSchemaManager->_execSql() at /root/symfony-app/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:930
Doctrine\DBAL\Schema\AbstractSchemaManager->createTable() at /root/symfony-app/vendor/symfony/doctrine-bridge/SchemaListener/AbstractSchemaListener.php:34
Symfony\Bridge\Doctrine\SchemaListener\AbstractSchemaListener::Symfony\Bridge\Doctrine\SchemaListener\{closure}() at /root/symfony-app/src/Messenger/DoctrineConnection.php:338
App\Messenger\DoctrineConnection->configureSchema() at /root/symfony-app/vendor/symfony/doctrine-messenger/Transport/DoctrineTransport.php:89
Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransport->configureSchema() at /root/symfony-app/vendor/symfony/doctrine-bridge/SchemaListener/MessengerTransportDoctrineSchemaListener.php:43
Symfony\Bridge\Doctrine\SchemaListener\MessengerTransportDoctrineSchemaListener->postGenerateSchema() at /root/symfony-app/vendor/symfony/doctrine-bridge/ContainerAwareEventManager.php:63
Symfony\Bridge\Doctrine\ContainerAwareEventManager->dispatchEvent() at /root/symfony-app/vendor/doctrine/orm/src/Tools/SchemaTool.php:421
Doctrine\ORM\Tools\SchemaTool->getSchemaFromMetadata() at /root/symfony-app/vendor/doctrine/orm/src/Tools/SchemaTool.php:980
Doctrine\ORM\Tools\SchemaTool->getUpdateSchemaSql() at /root/symfony-app/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/UpdateCommand.php:92
Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand->executeSchemaCommand() at /root/symfony-app/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/AbstractCommand.php:44
Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->doExecute() at /root/symfony-app/vendor/doctrine/orm/src/Tools/Console/CommandCompatibility.php:32
Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute() at /root/symfony-app/vendor/symfony/console/Command/Command.php:326
Symfony\Component\Console\Command\Command->run() at /root/symfony-app/vendor/symfony/console/Application.php:1096
Symfony\Component\Console\Application->doRunCommand() at /root/symfony-app/vendor/symfony/framework-bundle/Console/Application.php:126
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /root/symfony-app/vendor/symfony/console/Application.php:324
Symfony\Component\Console\Application->doRun() at /root/symfony-app/vendor/symfony/framework-bundle/Console/Application.php:80
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /root/symfony-app/vendor/symfony/console/Application.php:175
Symfony\Component\Console\Application->run() at /root/symfony-app/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /root/symfony-app/vendor/autoload_runtime.php:29
require_once() at /root/symfony-app/bin/console:14
```
This commit will change the code style in `getIsSameDatabaseChecker()`, use doctrine SchemaManager to create/drop the temp table, make it work on most case database instances.
|
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
|
Thank you @ywisax. |
DigitalOcean's mysql instance set the default config "sql_require_primary_key=true", it will cause
./bin/console doctrine:schema:update --dump-sqlthrow an Exception:This commit will change the code style in
getIsSameDatabaseChecker(), use doctrine SchemaManager to create/drop the temp table, make it work on most case database instances.