I have a problem that has kept me busy and wondering for several days now.
I need to have two seperate databases in Symfony3/Doctrine 2.5.4 with MySQL
database. There need to be relationships/foreign keys between tables from
both
databases, though. The respective entities are organized in two different
Bundles. The relationships are exclusively unidirectional from Bundle2 to
Bundle1,
because Bundle1 is supposed to be independent from Bundle2.
Going by (almost) everything I have read on this topic, this means it is
impossible to use two seperate EntityManagers, because relationships
between multiple EM is not supported.
So the only option I have is to use one EM but use schema annotations to
differentiate between the two databases.
So I have essentially configured two connections and one EM in the
config.yml:
doctrine:
dbal:
default_connection: connection1
connections:
connection1:
driver: ...
dbname: db1
[...]
connection2:
driver: ...
dbname: db2
[...]
orm:
auto_generate_proxy_classes: '%kernel.debug'
default_entity_manager: em1
entity_managers:
em1:
connection: connection1
mappings:
Bundle1: ~
Bundle2: ~
hydrators:
[...]
All entities from both bundles are annotated like this:
@ORM\Table(name="tablename", schema="db1") or @ORM\Table(name="tablename",
schema="db2")
Yet, whenever I call doctrine:schema:validate or try to update the schema
I am told that the database schema is in sync with the mapping files.
Calling doctrine:mapping:info reports correct mapping for all entites from
both Bundles.
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.