Roland
Roland

Reputation: 313

doctrine schema update for 2 entity managers (different databases)

Using Symfony 4.4, where I've configured 2 entity managers: [default, migrate]. The "Migrate" manager connects to another mysql database, and I can read entities from there -tested-.

Whenever I try to update my "default" manager schema with

php bin/console doctrine:schema:update --em="default"

I got the following error:

In SchemaException.php line 111:
                                                                
  The table with name 'myProject.document' already exists.  

This happend because the "default" manager and the "migrate" manager also have the "document" entity, but in 2 different databases.

I'd like to update only the "default" manager's schema, and ignoring the "migrate" (which is exists in another database and i'm using as read only from there).

Upvotes: 0

Views: 823

Answers (1)

Roland
Roland

Reputation: 313

i've found buried deep inside ;-)

/**
 * @ORM\Table(name="document", schema="otherDatabaseName")
 * @ORM\Entity(readOnly=true)
 */
class Document extends Base {

So your "migrate" manager which uses "document" entity in this case, have to get through the schema where you've definied the other database's name.

schema:update gonna run properly with or without the -em option

Upvotes: 1

Related Questions