Upgrade Rails to 5.1
What does this MR do?
EE version: gitlab-ee!9386
Upgrades Rails to latest 5.1 version. Biggest changes:
bigserialis default primary key in the schema.
build_selectchanged to select only the required fields if the model has
ignored_columns. https://github.com/rails/rails/blob/5-1-stable/activerecord/lib/active_record/relation/query_methods.rb#L1041. This is incompatiple with some migrations or background migration specs because rails keeps a statement cache in memory. So if a model with
ignored_columnsin a migration is used, the query with
select table.col1, table.col2is stored in the statement cache. If a different migration is then run and one of these columns is removed in the mean time, the query is invalid. Proper solution here is to not use the model but override it, like done in most migrations, but unfortunately not in all. Also for background migration specs you can clear all statement caches in
reset_column_in_all_models. I chose for a monkey patch because it seems not feasible to rewrite all migrations where rails model is used.
Model.new.attributesnow also returns encrypted attribute.
- There are still some places where
attribute_changed?is used, these will be addressed in the follow-up issue: gitlab-ee#9932
What are the relevant issue numbers?
Does this MR meet the acceptance criteria?
- Changelog entry added, if necessary
- Documentation created/updated via this MR
- Documentation reviewed by technical writer or follow-up review issue created
- Tests added for this feature/bug
- Tested in all supported browsers
- Conforms to the code review guidelines
- Conforms to the merge request performance guidelines
- Conforms to the style guides
- Conforms to the database guides
- Link to e2e tests MR added if this MR has Requires e2e tests label. See the Test Planning Process.
- Security reports checked/validated by reviewer