Open jayvdb opened 1 year ago
I like this topic , and your approach and Idea sounds right ... but how about just changing the Model / struct name and then running a special cli migration command that can now change the column name
I would love to contribute on this one
I don't think it's exclusive. I like the idea of having an attribute to indicate a rename AND being able to do it from a cli command.
I'd probably lean slightly towards having a butane-custom attribute for the rename, though it could recognize the serde alias
too.
@ugochukwu-850 thanks for your interest. I'd welcome a PR doing either or both of these things.
migrations::adb::Operation
supportsAddColumn
,RemoveColumn
andChangeColumn
, but has noRenameColumn
.Implementing the backend of rename column is easy for postgres which supports this, and looks like it might also be possible with sqlite per https://www.sqlite.org/lang_altertable.html
Then the question is how to expose that, so that the rename can be expressed in the Rust.
Maybe using
serde
'salias
to indicate the old column name, like:Once the rename has been stored in the migration, the
alias
should be able to be removed or kept for as long the code needs it. i.e. the migration system should recognise it has already done that migration, and not break anything if thealias
is retained or removed at any later time. The system should also be able to handlealias
being added to an existing, not renamed, field.