From e4679c66565d0ccae54ffc58a23083841e5585e7 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 31 Mar 2015 10:52:07 -0700 Subject: fix travis: use couchdb.admin.yml and pin travis ruby version to one that is installed on travis-ci.org --- lib/tasks/leap_web_core_tasks.rake | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'lib/tasks') diff --git a/lib/tasks/leap_web_core_tasks.rake b/lib/tasks/leap_web_core_tasks.rake index e446f93..6f5ea4e 100644 --- a/lib/tasks/leap_web_core_tasks.rake +++ b/lib/tasks/leap_web_core_tasks.rake @@ -22,7 +22,21 @@ namespace :cleanup do end end +def use_admin_conf(couchrest_model_class) + couchrest_model_class.configure do |conf| + conf.environment = Rails.env + conf.connection_config_file = File.join(Rails.root, 'config', 'couchdb.admin.yml') + end +end + namespace :db do + desc "Migrate all design documents (using couchdb.admin.yml)" + task :migrate => :environment do + use_admin_conf(CouchRest::Model::Base) + CouchRest::Model::Utils::Migrate.load_all_models + CouchRest::Model::Utils::Migrate.all_models + end + desc "Rotate the databases, as needed." task :rotate => :environment do # @@ -31,26 +45,19 @@ namespace :db do # override the default config twice. # - CouchRest::Model::Base.configure do |conf| - conf.environment = Rails.env - conf.connection_config_file = File.join(Rails.root, 'config', 'couchdb.admin.yml') - end + use_admin_conf(CouchRest::Model::Base) Token.rotate_database_now(:window => 1.day) + User.create_tmp_database! + User.design_doc.sync!(User.tmp_database) - CouchRest::Session::Document.configure do |conf| - conf.environment = Rails.env - conf.connection_config_file = File.join(Rails.root, 'config', 'couchdb.admin.yml') - end + use_admin_conf(CouchRest::Session::Document) CouchRest::Session::Document.rotate_database_now(:window => 1.day) end desc "Delete and recreate temporary databases." task :deletetmp => :environment do # db deletion and creation must be performed by admin - CouchRest::Model::Base.configure do |conf| - conf.environment = Rails.env - conf.connection_config_file = File.join(Rails.root, 'config', 'couchdb.admin.yml') - end + use_admin_conf(CouchRest::Model::Base) User.tmp_database.recreate! User.design_doc.sync!(User.tmp_database) end -- cgit v1.2.3