]> source.dussan.org Git - redmine.git/commitdiff
Removes column opt in enumerations table.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 25 Dec 2009 17:13:58 +0000 (17:13 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 25 Dec 2009 17:13:58 +0000 (17:13 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3240 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/document_category.rb
app/models/enumeration.rb
app/models/issue_priority.rb
app/models/time_entry_activity.rb
db/migrate/20091225164732_remove_enumerations_opt.rb [new file with mode: 0644]
lib/redmine/default_data/loader.rb
lib/tasks/migrate_from_mantis.rake
lib/tasks/migrate_from_trac.rake
test/fixtures/enumerations.yml

index e04db7d166ddfa5778873fd1dbc43a8803a7cdc2..0355b91851841b514d9873c0f85ec5677995417c 100644 (file)
@@ -19,8 +19,6 @@ class DocumentCategory < Enumeration
   has_many :documents, :foreign_key => 'category_id'
 
   OptionName = :enumeration_doc_categories
-  # Backwards compatiblity.  Can be removed post-0.9
-  OptName = 'DCAT'
 
   def option_name
     OptionName
index 4836229b17d4891a0dd81b063d252eeabceec507..3b7a434a7a4600a3a0ad0d67d42f1c9927836e45 100644 (file)
@@ -29,36 +29,6 @@ class Enumeration < ActiveRecord::Base
   validates_presence_of :name
   validates_uniqueness_of :name, :scope => [:type, :project_id]
   validates_length_of :name, :maximum => 30
-  
-  # Backwards compatiblity named_scopes.
-  # Can be removed post-0.9
-  named_scope :priorities, :conditions => { :type => "IssuePriority" }, :order => 'position' do
-    ActiveSupport::Deprecation.warn("Enumeration#priorities is deprecated, use the IssuePriority class. (#{Redmine::Info.issue(3007)})")
-    def default
-      find(:first, :conditions => { :is_default => true })
-    end
-  end
-
-  named_scope :document_categories, :conditions => { :type => "DocumentCategory" }, :order => 'position' do
-    ActiveSupport::Deprecation.warn("Enumeration#document_categories is deprecated, use the DocumentCategories class. (#{Redmine::Info.issue(3007)})")
-    def default
-      find(:first, :conditions => { :is_default => true })
-    end
-  end
-
-  named_scope :activities, :conditions => { :type => "TimeEntryActivity" }, :order => 'position' do
-    ActiveSupport::Deprecation.warn("Enumeration#activities is deprecated, use the TimeEntryActivity class. (#{Redmine::Info.issue(3007)})")
-    def default
-      find(:first, :conditions => { :is_default => true })
-    end
-  end
-  
-  named_scope :values, lambda {|type| { :conditions => { :type => type }, :order => 'position' } } do
-    def default
-      find(:first, :conditions => { :is_default => true })
-    end
-  end
-  # End backwards compatiblity named_scopes
 
   named_scope :shared, :conditions => { :project_id => nil }
   named_scope :active, :conditions => { :active => true }
@@ -80,12 +50,6 @@ class Enumeration < ActiveRecord::Base
     nil
   end
 
-  # Backwards compatiblity.  Can be removed post-0.9
-  def opt
-    ActiveSupport::Deprecation.warn("Enumeration#opt is deprecated, use the STI classes now. (#{Redmine::Info.issue(3007)})")
-    return OptName
-  end
-
   def before_save
     if is_default? && is_default_changed?
       Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type})
index cea0f0635195f5cda1f6fb771a40252bd8ed5c48..81c817b394d42b7f81053229cb43550f96a1dbb5 100644 (file)
@@ -19,8 +19,6 @@ class IssuePriority < Enumeration
   has_many :issues, :foreign_key => 'priority_id'
 
   OptionName = :enumeration_issue_priorities
-  # Backwards compatiblity.  Can be removed post-0.9
-  OptName = 'IPRI'
 
   def option_name
     OptionName
index 8e3567156eb09042303fb22ae65321d219699380..4a612ac9f24d99f89cf1f12ec2062e95add1b9a6 100644 (file)
@@ -19,8 +19,6 @@ class TimeEntryActivity < Enumeration
   has_many :time_entries, :foreign_key => 'activity_id'
 
   OptionName = :enumeration_activities
-  # Backwards compatiblity.  Can be removed post-0.9
-  OptName = 'ACTI'
   
   def option_name
     OptionName
diff --git a/db/migrate/20091225164732_remove_enumerations_opt.rb b/db/migrate/20091225164732_remove_enumerations_opt.rb
new file mode 100644 (file)
index 0000000..72c39e0
--- /dev/null
@@ -0,0 +1,12 @@
+class RemoveEnumerationsOpt < ActiveRecord::Migration
+  def self.up
+    remove_column :enumerations, :opt
+  end
+
+  def self.down
+    add_column :enumerations, :opt, :string, :limit => 4, :default => '', :null => false
+    Enumeration.update_all("opt = 'IPRI'", "type = 'IssuePriority'")
+    Enumeration.update_all("opt = 'DCAT'", "type = 'DocumentCategory'")
+    Enumeration.update_all("opt = 'ACTI'", "type = 'TimeEntryActivity'")
+  end
+end
index a8846672757da9383a5f88db62c83038ed73b941..7baeb976cfed6c252c3049c0007b1ffd7ad985f7 100644 (file)
@@ -160,17 +160,17 @@ module Redmine
             }
           
             # Enumerations
-            DocumentCategory.create!(:opt => "DCAT", :name => l(:default_doc_category_user), :position => 1)
-            DocumentCategory.create!(:opt => "DCAT", :name => l(:default_doc_category_tech), :position => 2)
+            DocumentCategory.create!(:name => l(:default_doc_category_user), :position => 1)
+            DocumentCategory.create!(:name => l(:default_doc_category_tech), :position => 2)
           
-            IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_low), :position => 1)
-            IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_normal), :position => 2, :is_default => true)
-            IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_high), :position => 3)
-            IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_urgent), :position => 4)
-            IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_immediate), :position => 5)
+            IssuePriority.create!(:name => l(:default_priority_low), :position => 1)
+            IssuePriority.create!(:name => l(:default_priority_normal), :position => 2, :is_default => true)
+            IssuePriority.create!(:name => l(:default_priority_high), :position => 3)
+            IssuePriority.create!(:name => l(:default_priority_urgent), :position => 4)
+            IssuePriority.create!(:name => l(:default_priority_immediate), :position => 5)
           
-            TimeEntryActivity.create!(:opt => "ACTI", :name => l(:default_activity_design), :position => 1)
-            TimeEntryActivity.create!(:opt => "ACTI", :name => l(:default_activity_development), :position => 2)
+            TimeEntryActivity.create!(:name => l(:default_activity_design), :position => 1)
+            TimeEntryActivity.create!(:name => l(:default_activity_development), :position => 2)
           end
           true
         end
index a7582a38a442c16998fb3cb404c37c1039756946..95722b12bc17fe4a8f5695fd53ddfe67f62b491f 100644 (file)
@@ -40,7 +40,7 @@ task :migrate_from_mantis => :environment do
                         90 => closed_status    # closed\r
                         }\r
                         \r
-      priorities = Enumeration.priorities\r
+      priorities = IssuePriority.all\r
       DEFAULT_PRIORITY = priorities[2]\r
       PRIORITY_MAPPING = {10 => priorities[1], # none\r
                           20 => priorities[1], # low\r
index 1902af8d0228d13f4a67f37bfc0bb6dbd2c034ea..e267a340f2ef29644a9b2f2d87d255b05c0354aa 100644 (file)
@@ -37,7 +37,7 @@ namespace :redmine do
                           'closed' => closed_status
                           }
 
-        priorities = Enumeration.priorities
+        priorities = IssuePriority.all
         DEFAULT_PRIORITY = priorities[0]
         PRIORITY_MAPPING = {'lowest' => priorities[0],
                             'low' => priorities[0],
index 5b9bc9297d3cf3df033c83bcd7cf8b1b3b1084bb..650a48c3e2157964176566da353549ae14a7af2e 100644 (file)
@@ -2,63 +2,53 @@
 enumerations_001: 
   name: Uncategorized
   id: 1
-  opt: DCAT
   type: DocumentCategory
   active: true
 enumerations_002: 
   name: User documentation
   id: 2
-  opt: DCAT
   type: DocumentCategory
   active: true
 enumerations_003: 
   name: Technical documentation
   id: 3
-  opt: DCAT
   type: DocumentCategory
   active: true
 enumerations_004: 
   name: Low
   id: 4
-  opt: IPRI
   type: IssuePriority
   active: true
 enumerations_005: 
   name: Normal
   id: 5
-  opt: IPRI
   type: IssuePriority
   is_default: true
   active: true
 enumerations_006: 
   name: High
   id: 6
-  opt: IPRI
   type: IssuePriority
   active: true
 enumerations_007: 
   name: Urgent
   id: 7
-  opt: IPRI
   type: IssuePriority
   active: true
 enumerations_008: 
   name: Immediate
   id: 8
-  opt: IPRI
   type: IssuePriority
   active: true
 enumerations_009: 
   name: Design
   id: 9
-  opt: ACTI
   type: TimeEntryActivity
   position: 1
   active: true
 enumerations_010: 
   name: Development
   id: 10
-  opt: ACTI
   type: TimeEntryActivity
   position: 2
   is_default: true
@@ -66,27 +56,23 @@ enumerations_010:
 enumerations_011: 
   name: QA
   id: 11
-  opt: ACTI
   type: TimeEntryActivity
   position: 3
   active: true
 enumerations_012:
   name: Default Enumeration
   id: 12
-  opt: ''
   type: Enumeration
   is_default: true
   active: true
 enumerations_013:
   name: Another Enumeration
   id: 13
-  opt: ''
   type: Enumeration
   active: true
 enumerations_014: 
   name: Inactive Activity
   id: 14
-  opt: ACTI
   type: TimeEntryActivity
   position: 4
   active: false