I have this little Rake task which I seem to end up putting into all
of my projects and I''m wondering if this might be of use to other
people as well or if there is a better way of accomplishing this.
It is especially useful during initial development when you may hose
your migrations and need to go back to fresh db where rake db:migrate
VERSION=0 will not work (because of a failure during an up migration
leaving your database in an inconsistent state).
Anyhow, here''s the task. I put it in lib/tasks/database.rake and then
type rake db:recreate
namespace :db do
desc "Drop and create the current database"
task :recreate => :environment do
abcs = ActiveRecord::Base.configurations
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
ActiveRecord::Base.connection.recreate_database(ActiveRecord::Base.connection.current_database)
end
end
Sincerely,
Anthony Eden
--
Email: anthonyeden-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cell: 808 782-5046
Current Location: Melbourne, FL
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---