mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Tables are recreated instead of renamed #6128
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 @crtl on GitHub (Dec 11, 2018).
Originally assigned to: @Ocramius on GitHub.
Bug Report (?)
Summary
After having created the database schema running
orm:schema-tool:create -f, adding the[table]-attribute toentityin the.dcm.xmldefinition and then runningorm:schema-tool:update, the tables were not renamed but new ones were created.Current behavior
Adding
tableattribute with a new table name in xml definition file causes creation of new table when runningorm:schema-tool:update.How to reproduce
orm:schema-tool:createtableattribute with a new table name toentityorm:schema-tool:updateExpected 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.
@Ocramius commented on GitHub (Dec 11, 2018):
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:
There is no persistent state involved, and there shouldn't be, as it would complicate the process even further.