[WIP] Add migration helper methods [skip ci] #102
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.
Related #95
Currently, I'm not asking for a thorough review, just POC validation.
This adds (documentation and usage examples provided inline with method definitions):
add_foreign_key_concurrently
. If we can updateactiverecord
dependency to>= 5.2
, then this won't be needed asadd_foreign_key ..., validate: false
can be used directlyupdate_column_in_batches
add_column_with_default
rename_column_concurrently
,undo_rename_column_concurrently
,cleanup_after_rename_column_concurrently
,undo_cleanup_after_rename_column_concurrently
- for working with renaming columnschange_column_type_concurrently
,cleanup_after_change_column_type_concurrently
While writing this, I have figured it out, that it will also be useful to add something like
rename_table_concurrently
. If you have other ideas of what can be useful to add, please share.Gitlab also has some code for background migrations for extra large tables. I do not considered them here to make this PR more digestible. Those will be added separately, if needed.
Todo: