Fix `datetime_with_timezone` multiple problems
timestamp
column on each table in MySQL is NOT NULL and defaults to CURRENT_TIMESTAMP on update
1. The first This is a MySQL "feature": https://bugs.mysql.com/bug.php?id=75098
This can cause unexpected master failures since we don't test MySQL on every branch, but we do on master, like in https://gitlab.com/gitlab-org/gitlab-ee/issues/3150#note_37391138.
Edit: This was worked around in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13560, but it is not working for @vsizov in the Rails 5 upgrade.
datetime_with_timezone
2. Current ActiveRecord monkeypatch doesn't always generate schema with See @yorickpeterse's example in this comment
I have a migration that changes the type of two columns from
datetime
todatetime_with_timezone
but they still get dumped ast.datetime
indb/schema.rb
3. Current ActiveRecord monkeypatch doesn't work in Rails 5
After Rails 5 upgrade, the schema will no longer be generated with datetime_with_timezone
columns, which will probably cause some confusion, and eventually inconsistent development/test DB setups.
This was due to the following:
Comment https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12841#note_35154488
FYI In rails 5, they significantly rewrote DB adapters so this hack https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/initializers/active_record_data_types.rb#L64 does not work anymore...
Comment https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12841#note_35174984
I reverted the origin version of the
config/initializers/active_record_data_types.rb
monkey patch. It should unblock this MR but re-introduce schema dump problems, see the git log https://gitlab.com/gitlab-org/gitlab-ce/commits/master/config/initializers/active_record_data_types.rb