Skip to content

Instantly share code, notes, and snippets.

@evizitei
Created May 25, 2009 17:21
Show Gist options
  • Save evizitei/117625 to your computer and use it in GitHub Desktop.
Save evizitei/117625 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