mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Include a table prefix listener that others can use or build upon #7165
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 @mpdude on GitHub (Jun 8, 2023).
Feature Request
Summary
At https://www.doctrine-project.org/projects/doctrine-orm/en/2.15/cookbook/sql-table-prefixes.html, example code for an event listener is shown that prepends a given prefix to all tables used by the ORM.
The suggestion is to improve this code a bit and include it in the ORM repo/package itself so that others can easily use it.
The improvement would be that an array of class namespace prefix => table prefix can be given. For any particular entity class, find the first array entry that aligns with the entity's FQCN (probably making sure we're splitting at
\only, right?) and use the corresponsing prefix.Then, make this configurable in e. g. DoctrineBundle.
Use case
I have a Symfony application and use two third-party bundles. Both bundles bring along an ORM entity classes, including
Acme\Entity\CategoryandSuperduperInc\Entity\Category. Both compete for thecategorytable name.If I could configure table name prefixes
Acme\Entity\=>acme_andSuperduperInc\Entity\=>superduper_, this could be resolved.