mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
workaround old mysql/mysql2 adapter incompatibility with MySQL 5.7.3+.
This commit is contained in:
parent
8e34c1e652
commit
fc3ac68474
2 changed files with 12 additions and 1 deletions
|
@ -1,7 +1,6 @@
|
||||||
require 'support/active_record/database_setup'
|
require 'support/active_record/database_setup'
|
||||||
require 'support/active_record/schema_setup'
|
require 'support/active_record/schema_setup'
|
||||||
|
|
||||||
|
|
||||||
module MySQL2Helper
|
module MySQL2Helper
|
||||||
puts "Active Record #{ActiveRecord::VERSION::STRING}, mysql2"
|
puts "Active Record #{ActiveRecord::VERSION::STRING}, mysql2"
|
||||||
|
|
||||||
|
@ -24,6 +23,7 @@ module MySQL2Helper
|
||||||
end
|
end
|
||||||
|
|
||||||
def active_record_mysql2_setup
|
def active_record_mysql2_setup
|
||||||
|
patch_mysql2_adapter
|
||||||
create_db
|
create_db
|
||||||
establish_connection
|
establish_connection
|
||||||
active_record_load_schema
|
active_record_load_schema
|
||||||
|
@ -32,6 +32,11 @@ module MySQL2Helper
|
||||||
def active_record_mysql2_connection
|
def active_record_mysql2_connection
|
||||||
ActiveRecord::Base.connection
|
ActiveRecord::Base.connection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def patch_mysql2_adapter
|
||||||
|
# remove DEFAULT NULL from column definition, which is an error on primary keys in MySQL 5.7.3+
|
||||||
|
ActiveRecord::ConnectionAdapters::Mysql2Adapter::NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
|
|
|
@ -23,6 +23,7 @@ module MySQLHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def active_record_mysql_setup
|
def active_record_mysql_setup
|
||||||
|
patch_mysql_adapter
|
||||||
create_db
|
create_db
|
||||||
establish_connection
|
establish_connection
|
||||||
active_record_load_schema
|
active_record_load_schema
|
||||||
|
@ -31,6 +32,11 @@ module MySQLHelper
|
||||||
def active_record_mysql_connection
|
def active_record_mysql_connection
|
||||||
ActiveRecord::Base.connection
|
ActiveRecord::Base.connection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def patch_mysql_adapter
|
||||||
|
# remove DEFAULT NULL from column definition, which is an error on primary keys in MySQL 5.7.3+
|
||||||
|
ActiveRecord::ConnectionAdapters::MysqlAdapter::NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue