summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2015-03-11 01:12:23 -0700
committerelijah <elijah@riseup.net>2015-03-17 22:36:27 -0700
commit9266c3ac58404894539e25e514d8d8a6775c701f (patch)
tree3beaa846b37aecdf933763564710c2e1042c03a3 /lib/tasks
parenta777c4c677e8cbd4f91c66a29ee1ecb347c5b8ab (diff)
add support for rotating tokens and sessions databases, and for a special tmp db for test users.
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/leap_web_core_tasks.rake35
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