From 738cf2e187f90cd7273ae0de610bfea49b4b799f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 3 Dec 2012 18:25:57 +0000 Subject: [PATCH] Replaces find(:first) calls in migrations. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10929 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- db/migrate/002_issue_move.rb | 2 +- db/migrate/003_issue_add_note.rb | 2 +- db/migrate/004_export_pdf.rb | 4 ++-- db/migrate/006_calendar_and_activity.rb | 6 +++--- db/migrate/007_create_journals.rb | 2 +- db/migrate/012_add_comments_permissions.rb | 4 ++-- db/migrate/014_add_queries_permissions.rb | 2 +- db/migrate/016_add_repositories_permissions.rb | 12 ++++++------ db/migrate/024_add_roadmap_permission.rb | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/db/migrate/002_issue_move.rb b/db/migrate/002_issue_move.rb index 085593e08..98e95d3b9 100644 --- a/db/migrate/002_issue_move.rb +++ b/db/migrate/002_issue_move.rb @@ -7,6 +7,6 @@ class IssueMove < ActiveRecord::Migration end def self.down - Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'move_issues']).destroy + Permission.where("controller=? and action=?", 'projects', 'move_issues').first.destroy end end diff --git a/db/migrate/003_issue_add_note.rb b/db/migrate/003_issue_add_note.rb index a2ab756ee..dabdb858f 100644 --- a/db/migrate/003_issue_add_note.rb +++ b/db/migrate/003_issue_add_note.rb @@ -7,6 +7,6 @@ class IssueAddNote < ActiveRecord::Migration end def self.down - Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'add_note']).destroy + Permission.where("controller=? and action=?", 'issues', 'add_note').first.destroy end end diff --git a/db/migrate/004_export_pdf.rb b/db/migrate/004_export_pdf.rb index 6ccd67eae..8d4ba0b3a 100644 --- a/db/migrate/004_export_pdf.rb +++ b/db/migrate/004_export_pdf.rb @@ -8,7 +8,7 @@ class ExportPdf < ActiveRecord::Migration end def self.down - Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'export_issues_pdf']).destroy - Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'export_pdf']).destroy + Permission.where("controller=? and action=?", 'projects', 'export_issues_pdf').first.destroy + Permission.where("controller=? and action=?", 'issues', 'export_pdf').first.destroy end end diff --git a/db/migrate/006_calendar_and_activity.rb b/db/migrate/006_calendar_and_activity.rb index 1cdc91d8e..a30979a21 100644 --- a/db/migrate/006_calendar_and_activity.rb +++ b/db/migrate/006_calendar_and_activity.rb @@ -9,8 +9,8 @@ class CalendarAndActivity < ActiveRecord::Migration end def self.down - Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'activity']).destroy - Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'calendar']).destroy - Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'gantt']).destroy + Permission.where("controller=? and action=?", 'projects', 'activity').first.destroy + Permission.where("controller=? and action=?", 'projects', 'calendar').first.destroy + Permission.where("controller=? and action=?", 'projects', 'gantt').first.destroy end end diff --git a/db/migrate/007_create_journals.rb b/db/migrate/007_create_journals.rb index e219ef67a..63bdd2374 100644 --- a/db/migrate/007_create_journals.rb +++ b/db/migrate/007_create_journals.rb @@ -51,6 +51,6 @@ class CreateJournals < ActiveRecord::Migration add_index "issue_histories", ["issue_id"], :name => "issue_histories_issue_id" - Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'history']).destroy + Permission.where("controller=? and action=?", 'issues', 'history').first.destroy end end diff --git a/db/migrate/012_add_comments_permissions.rb b/db/migrate/012_add_comments_permissions.rb index 2bbf87b02..91eed6443 100644 --- a/db/migrate/012_add_comments_permissions.rb +++ b/db/migrate/012_add_comments_permissions.rb @@ -8,7 +8,7 @@ class AddCommentsPermissions < ActiveRecord::Migration end def self.down - Permission.find(:first, :conditions => ["controller=? and action=?", 'news', 'add_comment']).destroy - Permission.find(:first, :conditions => ["controller=? and action=?", 'news', 'destroy_comment']).destroy + Permission.where("controller=? and action=?", 'news', 'add_comment').first.destroy + Permission.where("controller=? and action=?", 'news', 'destroy_comment').first.destroy end end diff --git a/db/migrate/014_add_queries_permissions.rb b/db/migrate/014_add_queries_permissions.rb index 34eba1e26..ae1f2455d 100644 --- a/db/migrate/014_add_queries_permissions.rb +++ b/db/migrate/014_add_queries_permissions.rb @@ -7,6 +7,6 @@ class AddQueriesPermissions < ActiveRecord::Migration end def self.down - Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'add_query']).destroy + Permission.where("controller=? and action=?", 'projects', 'add_query').first.destroy end end diff --git a/db/migrate/016_add_repositories_permissions.rb b/db/migrate/016_add_repositories_permissions.rb index 341707639..9fcddb09c 100644 --- a/db/migrate/016_add_repositories_permissions.rb +++ b/db/migrate/016_add_repositories_permissions.rb @@ -12,11 +12,11 @@ class AddRepositoriesPermissions < ActiveRecord::Migration end def self.down - Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'show']).destroy - Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'browse']).destroy - Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'entry']).destroy - Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'revisions']).destroy - Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'revision']).destroy - Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'diff']).destroy + Permission.where("controller=? and action=?", 'repositories', 'show').first.destroy + Permission.where("controller=? and action=?", 'repositories', 'browse').first.destroy + Permission.where("controller=? and action=?", 'repositories', 'entry').first.destroy + Permission.where("controller=? and action=?", 'repositories', 'revisions').first.destroy + Permission.where("controller=? and action=?", 'repositories', 'revision').first.destroy + Permission.where("controller=? and action=?", 'repositories', 'diff').first.destroy end end diff --git a/db/migrate/024_add_roadmap_permission.rb b/db/migrate/024_add_roadmap_permission.rb index 5c37beac1..f521e6025 100644 --- a/db/migrate/024_add_roadmap_permission.rb +++ b/db/migrate/024_add_roadmap_permission.rb @@ -7,6 +7,6 @@ class AddRoadmapPermission < ActiveRecord::Migration end def self.down - Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'roadmap']).destroy + Permission.where("controller=? and action=?", 'projects', 'roadmap').first.destroy end end