Rails4: db migrate: replace "Permission.find_by_controller_and_action"
git-svn-id: http://svn.redmine.org/redmine/trunk@12422 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
5c5ba0c61a
commit
9b5ce4b7b4
|
@ -3,16 +3,16 @@ class SetDocAndFilesNotifications < ActiveRecord::Migration
|
|||
class Permission < ActiveRecord::Base; end
|
||||
|
||||
def self.up
|
||||
Permission.find_by_controller_and_action("projects", "add_file").update_attribute(:mail_option, true)
|
||||
Permission.find_by_controller_and_action("projects", "add_document").update_attribute(:mail_option, true)
|
||||
Permission.find_by_controller_and_action("documents", "add_attachment").update_attribute(:mail_option, true)
|
||||
Permission.find_by_controller_and_action("issues", "add_attachment").update_attribute(:mail_option, true)
|
||||
Permission.where(:controller => "projects", :action => "add_file").each {|p| p.update_attribute(:mail_option, true)}
|
||||
Permission.where(:controller => "projects", :action => "add_document").each {|p| p.update_attribute(:mail_option, true)}
|
||||
Permission.where(:controller => "documents", :action => "add_attachment").each {|p| p.update_attribute(:mail_option, true)}
|
||||
Permission.where(:controller => "issues", :action => "add_attachment").each {|p| p.update_attribute(:mail_option, true)}
|
||||
end
|
||||
|
||||
def self.down
|
||||
Permission.find_by_controller_and_action("projects", "add_file").update_attribute(:mail_option, false)
|
||||
Permission.find_by_controller_and_action("projects", "add_document").update_attribute(:mail_option, false)
|
||||
Permission.find_by_controller_and_action("documents", "add_attachment").update_attribute(:mail_option, false)
|
||||
Permission.find_by_controller_and_action("issues", "add_attachment").update_attribute(:mail_option, false)
|
||||
Permission.where(:controller => "projects", :action => "add_file").each {|p| p.update_attribute(:mail_option, false)}
|
||||
Permission.where(:controller => "projects", :action => "add_document").each {|p| p.update_attribute(:mail_option, false)}
|
||||
Permission.where(:controller => "documents", :action => "add_attachment").each {|p| p.update_attribute(:mail_option, false)}
|
||||
Permission.where(:controller => "issues", :action => "add_attachment").each {|p| p.update_attribute(:mail_option, false)}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,6 @@ class AddSearchPermission < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
Permission.find_by_controller_and_action('projects', 'search').destroy
|
||||
Permission.where(:controller => "projects", :action => "search").each {|p| p.destroy}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,6 @@ class AddProjectsFeedsPermissions < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
Permission.find_by_controller_and_action('projects', 'feeds').destroy
|
||||
Permission.where(:controller => "projects", :action => "feeds").each {|p| p.destroy}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,6 @@ class AddTimelogPermissions < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
Permission.find_by_controller_and_action('timelog', 'edit').destroy
|
||||
Permission.where(:controller => "timelog", :action => "edit").each {|p| p.destroy}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ class AddRelationsPermissions < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
Permission.find_by_controller_and_action("issue_relations", "new").destroy
|
||||
Permission.find_by_controller_and_action("issue_relations", "destroy").destroy
|
||||
Permission.where(:controller => "issue_relations", :action => "new").each {|p| p.destroy}
|
||||
Permission.where(:controller => "issue_relations", :action => "destroy").each {|p| p.destroy}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,8 +9,8 @@ class AddBoardsPermissions < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
Permission.find_by_controller_and_action("boards", "new").destroy
|
||||
Permission.find_by_controller_and_action("boards", "edit").destroy
|
||||
Permission.find_by_controller_and_action("boards", "destroy").destroy
|
||||
Permission.where(:controller => "boards", :action => "new").each {|p| p.destroy}
|
||||
Permission.where(:controller => "boards", :action => "edit").each {|p| p.destroy}
|
||||
Permission.where(:controller => "boards", :action => "destroy").each {|p| p.destroy}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,6 @@ class AddWikiDestroyPagePermission < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
Permission.find_by_controller_and_action('wiki', 'destroy').destroy
|
||||
Permission.where(:controller => "wiki", :action => "destroy").each {|p| p.destroy}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ class AddWikiAttachmentsPermissions < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
Permission.find_by_controller_and_action('wiki', 'add_attachment').destroy
|
||||
Permission.find_by_controller_and_action('wiki', 'destroy_attachment').destroy
|
||||
Permission.where(:controller => "wiki", :action => "add_attachment").each {|p| p.destroy}
|
||||
Permission.where(:controller => "wiki", :action => "destroy_attachment").each {|p| p.destroy}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,6 @@ class AddRepositoriesChangesPermission < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
Permission.find_by_controller_and_action('repositories', 'changes').destroy
|
||||
Permission.where(:controller => "repositories", :action => "changes").each {|p| p.destroy}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue