From 9c5fbffbcbb1301572b3de3fb45d11de58d93212 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Fri, 27 Sep 2013 00:21:49 -0400 Subject: [PATCH] Migrate the test database to 0 instead of trying to "drop database". This way, the database credentials used for testing do not need create/drop database privileges. --- services/api/Rakefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/services/api/Rakefile b/services/api/Rakefile index 17d5fe7202..c4b921745f 100644 --- a/services/api/Rakefile +++ b/services/api/Rakefile @@ -5,3 +5,20 @@ require File.expand_path('../config/application', __FILE__) Server::Application.load_tasks + +# http://www.pervasivecode.com/blog/2007/09/22/making-rails-raketest-not-drop-your-pgsql-database/ +# +# don't drop the test database; migrate it back to 0 +Rake::TaskManager.class_eval do + def delete_task(task_name) + @tasks.delete(task_name.to_s) + end + Rake.application.delete_task("db:test:purge") +end +namespace :db do + namespace :test do + task :purge do + ActiveRecord::Migrator.migrate("db/migrate/", 0) + end + end +end -- 2.30.2