##// END OF EJS Templates
Rails4: db migrate: replace "Permission.find_by_controller_and_action"...
Toshi MARUYAMA -
r12147:9b5ce4b7b44b
parent child
Show More
@@ -3,16 +3,16 class SetDocAndFilesNotifications < ActiveRecord::Migration
3 class Permission < ActiveRecord::Base; end
3 class Permission < ActiveRecord::Base; end
4
4
5 def self.up
5 def self.up
6 Permission.find_by_controller_and_action("projects", "add_file").update_attribute(:mail_option, true)
6 Permission.where(:controller => "projects", :action => "add_file").each {|p| p.update_attribute(:mail_option, true)}
7 Permission.find_by_controller_and_action("projects", "add_document").update_attribute(:mail_option, true)
7 Permission.where(:controller => "projects", :action => "add_document").each {|p| p.update_attribute(:mail_option, true)}
8 Permission.find_by_controller_and_action("documents", "add_attachment").update_attribute(:mail_option, true)
8 Permission.where(:controller => "documents", :action => "add_attachment").each {|p| p.update_attribute(:mail_option, true)}
9 Permission.find_by_controller_and_action("issues", "add_attachment").update_attribute(:mail_option, true)
9 Permission.where(:controller => "issues", :action => "add_attachment").each {|p| p.update_attribute(:mail_option, true)}
10 end
10 end
11
11
12 def self.down
12 def self.down
13 Permission.find_by_controller_and_action("projects", "add_file").update_attribute(:mail_option, false)
13 Permission.where(:controller => "projects", :action => "add_file").each {|p| p.update_attribute(:mail_option, false)}
14 Permission.find_by_controller_and_action("projects", "add_document").update_attribute(:mail_option, false)
14 Permission.where(:controller => "projects", :action => "add_document").each {|p| p.update_attribute(:mail_option, false)}
15 Permission.find_by_controller_and_action("documents", "add_attachment").update_attribute(:mail_option, false)
15 Permission.where(:controller => "documents", :action => "add_attachment").each {|p| p.update_attribute(:mail_option, false)}
16 Permission.find_by_controller_and_action("issues", "add_attachment").update_attribute(:mail_option, false)
16 Permission.where(:controller => "issues", :action => "add_attachment").each {|p| p.update_attribute(:mail_option, false)}
17 end
17 end
18 end
18 end
@@ -7,6 +7,6 class AddSearchPermission < ActiveRecord::Migration
7 end
7 end
8
8
9 def self.down
9 def self.down
10 Permission.find_by_controller_and_action('projects', 'search').destroy
10 Permission.where(:controller => "projects", :action => "search").each {|p| p.destroy}
11 end
11 end
12 end
12 end
@@ -7,6 +7,6 class AddProjectsFeedsPermissions < ActiveRecord::Migration
7 end
7 end
8
8
9 def self.down
9 def self.down
10 Permission.find_by_controller_and_action('projects', 'feeds').destroy
10 Permission.where(:controller => "projects", :action => "feeds").each {|p| p.destroy}
11 end
11 end
12 end
12 end
@@ -7,6 +7,6 class AddTimelogPermissions < ActiveRecord::Migration
7 end
7 end
8
8
9 def self.down
9 def self.down
10 Permission.find_by_controller_and_action('timelog', 'edit').destroy
10 Permission.where(:controller => "timelog", :action => "edit").each {|p| p.destroy}
11 end
11 end
12 end
12 end
@@ -8,7 +8,7 class AddRelationsPermissions < ActiveRecord::Migration
8 end
8 end
9
9
10 def self.down
10 def self.down
11 Permission.find_by_controller_and_action("issue_relations", "new").destroy
11 Permission.where(:controller => "issue_relations", :action => "new").each {|p| p.destroy}
12 Permission.find_by_controller_and_action("issue_relations", "destroy").destroy
12 Permission.where(:controller => "issue_relations", :action => "destroy").each {|p| p.destroy}
13 end
13 end
14 end
14 end
@@ -9,8 +9,8 class AddBoardsPermissions < ActiveRecord::Migration
9 end
9 end
10
10
11 def self.down
11 def self.down
12 Permission.find_by_controller_and_action("boards", "new").destroy
12 Permission.where(:controller => "boards", :action => "new").each {|p| p.destroy}
13 Permission.find_by_controller_and_action("boards", "edit").destroy
13 Permission.where(:controller => "boards", :action => "edit").each {|p| p.destroy}
14 Permission.find_by_controller_and_action("boards", "destroy").destroy
14 Permission.where(:controller => "boards", :action => "destroy").each {|p| p.destroy}
15 end
15 end
16 end
16 end
@@ -7,6 +7,6 class AddWikiDestroyPagePermission < ActiveRecord::Migration
7 end
7 end
8
8
9 def self.down
9 def self.down
10 Permission.find_by_controller_and_action('wiki', 'destroy').destroy
10 Permission.where(:controller => "wiki", :action => "destroy").each {|p| p.destroy}
11 end
11 end
12 end
12 end
@@ -8,7 +8,7 class AddWikiAttachmentsPermissions < ActiveRecord::Migration
8 end
8 end
9
9
10 def self.down
10 def self.down
11 Permission.find_by_controller_and_action('wiki', 'add_attachment').destroy
11 Permission.where(:controller => "wiki", :action => "add_attachment").each {|p| p.destroy}
12 Permission.find_by_controller_and_action('wiki', 'destroy_attachment').destroy
12 Permission.where(:controller => "wiki", :action => "destroy_attachment").each {|p| p.destroy}
13 end
13 end
14 end
14 end
@@ -7,6 +7,6 class AddRepositoriesChangesPermission < ActiveRecord::Migration
7 end
7 end
8
8
9 def self.down
9 def self.down
10 Permission.find_by_controller_and_action('repositories', 'changes').destroy
10 Permission.where(:controller => "repositories", :action => "changes").each {|p| p.destroy}
11 end
11 end
12 end
12 end
General Comments 0
You need to be logged in to leave comments. Login now