Created
March 21, 2018 20:47
-
-
Save blimmer/1ef562ac5981dd8f65653075f16c1157 to your computer and use it in GitHub Desktop.
Rails Issue #30947 Workaround
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This patch is to work around this bug in Rails 5.0.x and 5.1.x | |
# https://github.com/rails/rails/issues/30947 | |
# Because we use SQLite for tests and MySQL in prod, having the options hash | |
# containing ENGINE=InnoDB causes problems when we try to prepare the test database. | |
# | |
# Because of this, we need to remove those options from the generated schema.rb file. | |
# Here is the source that's setting `options` | |
# https://github.com/rails/rails/blob/81787a895126ead62a2859b33eccbbb74ef38892/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb#L561 | |
# | |
# This should be removed for Rails 5.2 ++ | |
module TableOptionsScrubber | |
def self.prepended(_base) | |
raise('Please remove the monkey patch for schema options for Rails 5.2.x') if Gem::Version.new(Rails.version) >= Gem::Version.new(5.2) | |
end | |
def table_options(table_name) | |
to = super | |
to.delete(:options) | |
to | |
end | |
end | |
if ActiveRecord::Base.is_mysql_connection? | |
module ActiveRecord | |
module ConnectionAdapters | |
class AbstractMysqlAdapter | |
prepend TableOptionsScrubber | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment