Created
May 25, 2009 17:21
-
-
Save evizitei/117625 to your computer and use it in GitHub Desktop.
This file contains 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 characters
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