mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Add column to table without related property on its entity #5398
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 @koemeet on GitHub (Jan 30, 2017).
Originally assigned to: @Ocramius on GitHub.
I wanted to implement multi tenancy for an existing project using Doctrine without changing their metadata files or subclassing their models to add an extra field. Would it be easy/possible to extend Doctrine in a way that it adds a specific column to the table of an entity without having a property on that entity that represents that column? This way the models stay intact and you could use a SQL filter to filter down on that column to achieve multi tenancy.
Are there people who implemented something similar or have tips on how this can be done with Doctrine ORM?
@Ocramius commented on GitHub (Jan 30, 2017):
You'd just add a column in a manual migration: this is not something that can be done in the metadata API, since every field expects a matching reflection field.
@koemeet commented on GitHub (Jan 30, 2017):
Thanks for the fast response, wow! 😄
@lcobucci commented on GitHub (Jan 31, 2017):
@steffenbrem sometime ago I've created something based on
Doctrine\DBAL\Sharding\PoolingShardConnectionand a customDoctrine\DBAL\Sharding\ShardChoser\ShardChoserto implement multitenancy but I had a different schema for each tenant (with the same mapping) and everything worked just fine.