Skip to content

Instantly share code, notes, and snippets.

@pkuczynski pkuczynski/db.rake
Created Jan 28, 2014

Embed
What would you like to do?
Loading data from SQL file in rake task
desc 'Load data from SQL file'
task :load_data => :environment do
puts 'Loading db/data.sql'
sql = File.read("#{Rails.root}/db/data.sql")
statements = sql.split(/;$/)
statements.pop # the last empty statement
statements.each do |statement|
ActiveRecord::Base.connection.execute(statement)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.