Skip to content

Instantly share code, notes, and snippets.

@chewbranca
Forked from evizitei/db.rake
Created May 25, 2009 19:27
Show Gist options
  • Save chewbranca/117678 to your computer and use it in GitHub Desktop.
Save chewbranca/117678 to your computer and use it in GitHub Desktop.
namespace :db do
desc "abort rake if using bad memory techniques"
task :safety_migrate => :environment do
path = "#{RAILS_ROOT}/db/migrate/"
migration_directory = Dir.new(path)
proceed = true
migration_directory.each do |file|
if file != "." and file != ".."
migration = File.open("#{path}#{file}")
text = migration.read
if text =~ /\.all[\s|\(|\.]/
proceed = false
puts "migration #{file} contains a memory problem!"
end
end
end
Rake::Task['db:migrate'].invoke if proceed
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment