diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/leap_web_core_tasks.rake | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/lib/tasks/leap_web_core_tasks.rake b/lib/tasks/leap_web_core_tasks.rake index ec6abac..e446f93 100644 --- a/lib/tasks/leap_web_core_tasks.rake +++ b/lib/tasks/leap_web_core_tasks.rake @@ -8,7 +8,6 @@ namespace :couchrest do end namespace :cleanup do - desc "Cleanup all expired session documents" task :sessions => :environment do # make sure this is the same as in @@ -23,3 +22,37 @@ namespace :cleanup do end end +namespace :db do + desc "Rotate the databases, as needed." + task :rotate => :environment do + # + # db rotation must be performed by admin, and since + # CouchRest::Session::Document is not a CouchRest::Model, we need to + # 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 + Token.rotate_database_now(:window => 1.day) + + CouchRest::Session::Document.configure do |conf| + conf.environment = Rails.env + conf.connection_config_file = File.join(Rails.root, 'config', 'couchdb.admin.yml') + end + 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 + User.tmp_database.recreate! + User.design_doc.sync!(User.tmp_database) + end + +end |