Tables are recreated instead of renamed #6128

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

Originally created by @crtl on GitHub (Dec 11, 2018).

Originally assigned to: @Ocramius on GitHub.

Bug Report (?)

Q A
BC Break no
Version 2.6.3

Summary

After having created the database schema running orm:schema-tool:create -f, adding the [table]-attribute to entity in the .dcm.xml definition and then running orm:schema-tool:update, the tables were not renamed but new ones were created.

Current behavior

Adding table attribute with a new table name in xml definition file causes creation of new table when running orm:schema-tool:update.

How to reproduce

  1. Create a xml definition using default table names and run orm:schema-tool:create
  2. Add a table attribute with a new table name to entity
  3. Run orm:schema-tool:update
  4. A new table with the new name was created and the old one still exists

Expected behavior

Existing table should be renamed or old one deleted?

PS:
While writing this I noticed the dilemma of the situation, how should doctrine know what table to rename if it does not have its old name.
My first solution would be to introduce an file cache to keep track of the database status but I dont know if this fits doctrines philosophy.

Originally created by @crtl on GitHub (Dec 11, 2018). Originally assigned to: @Ocramius on GitHub. ### Bug Report (?) <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | no | Version | 2.6.3 #### Summary After having created the database schema running `orm:schema-tool:create -f`, adding the `[table]`-attribute to `entity` in the `.dcm.xml` definition and then running `orm:schema-tool:update`, the tables were not renamed but new ones were created. #### Current behavior Adding `table` attribute with a new table name in xml definition file causes creation of new table when running `orm:schema-tool:update`. #### How to reproduce 1. Create a xml definition using default table names and run `orm:schema-tool:create` 2. Add a `table` attribute with a new table name to `entity` 3. Run `orm:schema-tool:update` 4. A new table with the new name was created and the old one still exists #### Expected behavior Existing table should be renamed or old one deleted? PS: While writing this I noticed the dilemma of the situation, how should doctrine know what table to rename if it does not have its old name. My first solution would be to introduce an file cache to keep track of the database status but I dont know if this fits doctrines philosophy.
admin added the BugInvalid labels 2026-01-22 15:27:12 +01:00
admin closed this issue 2026-01-22 15:27:12 +01:00
Author
Owner

@Ocramius commented on GitHub (Dec 11, 2018):

Adding table attribute with a new table name in xml definition file causes creation of new table when running

This is correct/expected, as there is no way to recognise a table rename in a safe way. Keeping some state about currently existing schema is not up to the ORM. What the ORM does is:

compareSchema :: Schema -> Schema -> SchemaDiff

There is no persistent state involved, and there shouldn't be, as it would complicate the process even further.

@Ocramius commented on GitHub (Dec 11, 2018): > Adding `table` attribute with a new table name in xml definition file causes creation of new table when running This is correct/expected, as there is no way to recognise a table rename in a safe way. Keeping some state about currently existing schema is not up to the ORM. What the ORM does is: ```php compareSchema :: Schema -> Schema -> SchemaDiff ``` There is no persistent state involved, and there shouldn't be, as it would complicate the process even further.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6128