Add explicit renameColumn method for Table #6078
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add a
renameColumn
in theTable
classThis allow to create migration with schemas that rename columns explicitely, which is a missing feature
Right now only implicit detection is done (it looks for added columns with the same definition as a dropped column), and that means if you change an option or the type of the column, it will not consider it as a rename anymore and instead will drop and recreate, by being explicit, this is not a problem anymore
This PR allows the following migration, without losing the column data
Which before would have to drop the column and recreate it, as well as needing a full redefinition of the column, and losing the data in the process
PS: I'm building a feature for the
doctrine/migration
package to generate diffs of schema, directly usingSchema
instead of platform specific sql and without thisrenameColumn
this would be impossible