]> git.openstreetmap.org Git - rails.git/blob - db/migrate/041_add_fine_o_auth_permissions.rb
Combine migrations into one
[rails.git] / db / migrate / 041_add_fine_o_auth_permissions.rb
1 class AddFineOAuthPermissions < ActiveRecord::Migration[5.0]
2   PERMISSIONS = [:allow_read_prefs, :allow_write_prefs, :allow_write_diary, :allow_write_api, :allow_read_gpx, :allow_write_gpx].freeze
3
4   def self.up
5     PERMISSIONS.each do |perm|
6       # add fine-grained permissions columns for OAuth tokens, allowing people to
7       # give permissions to parts of the site only.
8       add_column :oauth_tokens, perm, :boolean, :null => false, :default => false
9
10       # add fine-grained permissions columns for client applications, allowing the
11       # client applications to request particular privileges.
12       add_column :client_applications, perm, :boolean, :null => false, :default => false
13     end
14   end
15
16   def self.down
17     PERMISSIONS.each do |perm|
18       remove_column :oauth_tokens, perm
19       remove_column :client_applications, perm
20     end
21   end
22 end