Support for dropping columns from a database
tdimitrov opened this issue · 9 comments
It would be really nice to have support for dropping arbitrary (or just the last) column from a Database
instance.
Do you need to change the options of the drop column?
Do you need to change the options of the drop column?
Probably stupid question, but why would I want to change the options of a column which is going away?
you can have an ordered indexed column and switch to non ordered one, or on hash indexed use preimage or something else, I think I will implement an optional change (make sense to me to have it).
@cheme Changing these options while preserving data is out of scope of this issue. As for the case when loosing data isacceptable, we already have add_column
. So remove_column
followed by add_column
should be enough.
What kind of "drop" is expected here? Removing a column entirely (and shifting following column indicies)? Or simply clearing all data?
I am implementing a full removal (remove at file level, so it is simple to reset different option).
With no indices shift.
I think proper behaviour for actually removing a column would be to shift following columns and rename their files.
As @tdimitrov suggested, we can just support removing the last column for now. In which case there's no need to rename/move anything.
I don t know if the shift could not be something that force user to manage two set of column index so a bit of additional work for him.
Maybe providing an api to move column would work Db::move_column(options, from, to)
. This way the shift is at convenience of the user.
you can have an ordered indexed column and switch to non ordered one, or on hash indexed use preimage or something else, I think I will implement an optional change (make sense to me to have it).
No. For my particular case - I want to drop all the data and remove the column from the metadata.
Removing any column would be nice. drop_last
+ move_column
is also acceptable.