-
-
Save jgomo3/b4b754a2c7794f55cf62738afa7fef47 to your computer and use it in GitHub Desktop.
Revisions
-
seyhunak created this gist
Dec 7, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ unless Rails.env.production? connection = ActiveRecord::Base.connection connection.tables.each do |table| connection.execute("TRUNCATE #{table}") unless table == "schema_migrations" end sql = File.read('db/import.sql') statements = sql.split(/;$/) statements.pop ActiveRecord::Base.transaction do statements.each do |statement| connection.execute(statement) end end end