Created
November 10, 2014 17:20
-
-
Save ain/96baea65c3422548fc90 to your computer and use it in GitHub Desktop.
Rake task to patch seed_migrate table reset failure on db:reset
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 characters
# Call with rake app:db:reset | |
namespace :app do | |
namespace :db do | |
# Patches seed_migration issue #22 | |
desc "Reset database incl. seeding migration" | |
task :reset => :environment do | |
puts "Resetting database..." | |
begin | |
Rake::Task["db:reset"].invoke | |
ActiveRecord::Base.connection.execute("TRUNCATE #{SeedMigration.migration_table_name};") | |
Rake::Task["seed:migrate"].invoke | |
rescue | |
puts "Reset failed." | |
raise | |
end | |
puts "Reset successful. Data seeded." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment