Commit 4eb4064c authored by marutosijp's avatar marutosijp

Rails4: db migrate: replace "Permission.find_by_controller_and_action"

git-svn-id: https://svn.redmine.org/redmine/trunk@12422 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent c6639339
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment