]> git.openstreetmap.org Git - rails.git/blob - vendor/plugins/open_id_authentication/tasks/open_id_authentication_tasks.rake
Merge branch 'master' into openid
[rails.git] / vendor / plugins / open_id_authentication / tasks / open_id_authentication_tasks.rake
1 namespace :open_id_authentication do
2   namespace :db do
3     desc "Creates authentication tables for use with OpenIdAuthentication"
4     task :create => :environment do
5       generate_migration(["open_id_authentication_tables", "add_open_id_authentication_tables"])
6     end
7
8     desc "Upgrade authentication tables from ruby-openid 1.x.x to 2.x.x"
9     task :upgrade => :environment do
10       generate_migration(["upgrade_open_id_authentication_tables", "upgrade_open_id_authentication_tables"])
11     end
12
13     def generate_migration(args)
14       require 'rails_generator'
15       require 'rails_generator/scripts/generate'
16
17       if ActiveRecord::Base.connection.supports_migrations?
18         Rails::Generator::Scripts::Generate.new.run(args)
19       else
20         raise "Task unavailable to this database (no migration support)"
21       end
22     end
23
24     desc "Clear the authentication tables"
25     task :clear => :environment do
26       OpenIdAuthentication::DbStore.cleanup_nonces
27       OpenIdAuthentication::DbStore.cleanup_associations
28     end
29   end
30 end