1ec356a0b5
* `MysqlDateTimeWithTimeZone` inherits from `ActiveRecord::Type::DateTime` (`MysqlDateTime` is not present in Rails 5) * explicitly set `NULL` default value for `merge_request_diff_files`'s `diff` column (otherwise empty string is used in a migration) and empty string is not allowed for text/blob fields in Mysql * disable NO_ZERO_DATE mode for all Mysql DB connections, otherwise SQL queries fail on inserting `0` value for `created_at` column
18 lines
729 B
Ruby
18 lines
729 B
Ruby
# Disable NO_ZERO_DATE mode for mysql in rails 5.
|
|
# We use zero date as a default value
|
|
# (config/initializers/active_record_mysql_timestamp.rb), in
|
|
# Rails 5 using zero date fails by default (https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/75450216)
|
|
# and NO_ZERO_DATE has to be explicitly disabled. Disabling strict mode
|
|
# is not sufficient.
|
|
|
|
require 'active_record/connection_adapters/abstract_mysql_adapter'
|
|
|
|
module MysqlZeroDate
|
|
def configure_connection
|
|
super
|
|
|
|
@connection.query "SET @@SESSION.sql_mode = REPLACE(@@SESSION.sql_mode, 'NO_ZERO_DATE', '');" # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
|
end
|
|
end
|
|
|
|
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.prepend(MysqlZeroDate) if Gitlab.rails5?
|