- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
class CheckDatabaseYmlEncoding < ActiveRecord::Migration
def self.up
config = Rails::Configuration.new
['development', 'production' ].each { |env|
db_config = config.database_configuration[env];
if db_config
if db_config['encoding'] != 'utf8'
msg = "please use encoding: utf8 in database.yml's #{env} configuration"
Rails.logger.error(msg)
raise msg
else
Rails.logger.info("database.yml's #{env} configuration is using encoding: utf8. Good !" )
end
else
Rails.logger.error("#{env} is missing in database.yml" )
end
}
end
def self.down
end
end