Mysql 在Rails上的架构中设置全局变量

Mysql 在Rails上的架构中设置全局变量,mysql,ruby-on-rails,ruby-on-rails-3,Mysql,Ruby On Rails,Ruby On Rails 3,使用Rails3.2和MySQL。我想在Rails应用程序中为MySQL设置一些全局变量,而不是第一次手动设置。我可以把它放在schema.rb中吗 # schema.rb ActiveRecord::Base.connection.execute("SET GLOBAL binlog_format = 'MIXED';") ActiveRecord::Schema.define(:version => 20140202070057) do create_table "curren

使用Rails3.2和MySQL。我想在Rails应用程序中为MySQL设置一些全局变量,而不是第一次手动设置。我可以把它放在schema.rb中吗

# schema.rb
ActiveRecord::Base.connection.execute("SET GLOBAL binlog_format = 'MIXED';")

ActiveRecord::Schema.define(:version => 20140202070057) do

  create_table "currencies", :force => true do |t|
    t.string   "name"
    ...
  end

  ...
end

因此,当我第一次运行
db:setup
时,它会设置全局变量。

db/schema.rb
文件是一个自动生成的文件。而是添加迁移脚本或rake任务

例如:

namespace :db do
  task :set_binlog_format => :environment do
    ActiveRecord::Base.connection.execute("SET GLOBAL binlog_format = 'MIXED';")
  end
  task :setup => :set_binlog_format
end