mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Permission denied when creating schema for primary/replicas #6937
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @fmarchalemisys on GitHub (Mar 2, 2022).
Bug Report
Summary
Creating the schema from the command line fails if a primary/replica configuration is used.
SQL commands are sent to the replica instead of the primary db.
The culprit is SchemaTool
It executes CREATE statements with
executeQuery($sql)instead ofexecuteStatement($sql).Current behavior
Creating the schema fails due to CREATE statement being denied on replica. The replica is read only. The schema can't be created on the replica.
How to reproduce
Unless you have two db servers configured as master/slave, the setup can be replicated on a single db server. Create a R/W user to simulate the primary and a R/O user with SELECT permission to simulate the replica.
Run the command:
Expected behavior
SQL CREATE statements must be sent to the primary.
CREATE statements are not queries. SchemaTool must call
executeStatement($sql).@leuchtdiode commented on GitHub (Apr 4, 2022):
Experienced this issue as well. Schema tool is trying to execute statements on replicas (which are in read-only mode in my setup). It should only be executed on primary only.
@eichie commented on GitHub (Apr 11, 2022):
+1
@elpoutro commented on GitHub (Jan 18, 2023):
Same issue with "php bin/console doctrine:schema:update" since update form doctrine 2.3 to 2.8.
@pich commented on GitHub (Apr 12, 2023):
+1
@greg0ire commented on GitHub (Apr 12, 2023):
Fixed in https://github.com/doctrine/orm/releases/tag/2.14.2
@pich commented on GitHub (Apr 13, 2023):
Thanks. Great job @simPod & @greg0ire . I owe you guys a beer :)