[Bug] CLI doctrine:schema:update throws an exception for many to many relationship when already exists a join table #5245

Closed
opened 2026-01-22 15:02:31 +01:00 by admin · 1 comment
Owner

Originally created by @raul782 on GitHub (Sep 11, 2016).

Originally assigned to: @Ocramius on GitHub.

Given a many to many relationship, between author and book, implemented in a project as Book, Author, and BookAuthor entity.
It throws an exception when trying to update the database through a CLI command.

$php app/console doctrine:schema:update --dump-sql

It will throw an exception

[Doctrine\DBAL\Schema\SchemaException]
The table with name 'db.book_author' already exists.

The reason is because, the update method is always trying to create a join table without checking in the scenario of the command: doctrine:schema:update if the table already exist. Which is a perfect valid action.

Similar Issue: https://github.com/doctrine/doctrine2/issues/3536

Originally created by @raul782 on GitHub (Sep 11, 2016). Originally assigned to: @Ocramius on GitHub. Given a many to many relationship, between author and book, implemented in a project as Book, Author, and BookAuthor entity. It throws an exception when trying to update the database through a CLI command. ``` $php app/console doctrine:schema:update --dump-sql ``` It will throw an exception ``` [Doctrine\DBAL\Schema\SchemaException] The table with name 'db.book_author' already exists. ``` The reason is because, the update method is always trying to create a join table without checking in the scenario of the command: doctrine:schema:update if the table already exist. Which is a perfect valid action. Similar Issue: https://github.com/doctrine/doctrine2/issues/3536
admin added the BugDuplicate labels 2026-01-22 15:02:31 +01:00
admin closed this issue 2026-01-22 15:02:32 +01:00
Author
Owner

@Ma27 commented on GitHub (Jan 3, 2017):

I think that this can be closed as well as #6027 has been closed (contains the same issue)

@Ma27 commented on GitHub (Jan 3, 2017): I think that this can be closed as well as #6027 has been closed (contains the same issue)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5245