##// END OF EJS Templates
Removes column opt in enumerations table....
Jean-Philippe Lang -
r3126:8db9ecef08ee
parent child
Show More
@@ -0,0 +1,12
1 class RemoveEnumerationsOpt < ActiveRecord::Migration
2 def self.up
3 remove_column :enumerations, :opt
4 end
5
6 def self.down
7 add_column :enumerations, :opt, :string, :limit => 4, :default => '', :null => false
8 Enumeration.update_all("opt = 'IPRI'", "type = 'IssuePriority'")
9 Enumeration.update_all("opt = 'DCAT'", "type = 'DocumentCategory'")
10 Enumeration.update_all("opt = 'ACTI'", "type = 'TimeEntryActivity'")
11 end
12 end
@@ -19,8 +19,6 class DocumentCategory < Enumeration
19 19 has_many :documents, :foreign_key => 'category_id'
20 20
21 21 OptionName = :enumeration_doc_categories
22 # Backwards compatiblity. Can be removed post-0.9
23 OptName = 'DCAT'
24 22
25 23 def option_name
26 24 OptionName
@@ -29,36 +29,6 class Enumeration < ActiveRecord::Base
29 29 validates_presence_of :name
30 30 validates_uniqueness_of :name, :scope => [:type, :project_id]
31 31 validates_length_of :name, :maximum => 30
32
33 # Backwards compatiblity named_scopes.
34 # Can be removed post-0.9
35 named_scope :priorities, :conditions => { :type => "IssuePriority" }, :order => 'position' do
36 ActiveSupport::Deprecation.warn("Enumeration#priorities is deprecated, use the IssuePriority class. (#{Redmine::Info.issue(3007)})")
37 def default
38 find(:first, :conditions => { :is_default => true })
39 end
40 end
41
42 named_scope :document_categories, :conditions => { :type => "DocumentCategory" }, :order => 'position' do
43 ActiveSupport::Deprecation.warn("Enumeration#document_categories is deprecated, use the DocumentCategories class. (#{Redmine::Info.issue(3007)})")
44 def default
45 find(:first, :conditions => { :is_default => true })
46 end
47 end
48
49 named_scope :activities, :conditions => { :type => "TimeEntryActivity" }, :order => 'position' do
50 ActiveSupport::Deprecation.warn("Enumeration#activities is deprecated, use the TimeEntryActivity class. (#{Redmine::Info.issue(3007)})")
51 def default
52 find(:first, :conditions => { :is_default => true })
53 end
54 end
55
56 named_scope :values, lambda {|type| { :conditions => { :type => type }, :order => 'position' } } do
57 def default
58 find(:first, :conditions => { :is_default => true })
59 end
60 end
61 # End backwards compatiblity named_scopes
62 32
63 33 named_scope :shared, :conditions => { :project_id => nil }
64 34 named_scope :active, :conditions => { :active => true }
@@ -80,12 +50,6 class Enumeration < ActiveRecord::Base
80 50 nil
81 51 end
82 52
83 # Backwards compatiblity. Can be removed post-0.9
84 def opt
85 ActiveSupport::Deprecation.warn("Enumeration#opt is deprecated, use the STI classes now. (#{Redmine::Info.issue(3007)})")
86 return OptName
87 end
88
89 53 def before_save
90 54 if is_default? && is_default_changed?
91 55 Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type})
@@ -19,8 +19,6 class IssuePriority < Enumeration
19 19 has_many :issues, :foreign_key => 'priority_id'
20 20
21 21 OptionName = :enumeration_issue_priorities
22 # Backwards compatiblity. Can be removed post-0.9
23 OptName = 'IPRI'
24 22
25 23 def option_name
26 24 OptionName
@@ -19,8 +19,6 class TimeEntryActivity < Enumeration
19 19 has_many :time_entries, :foreign_key => 'activity_id'
20 20
21 21 OptionName = :enumeration_activities
22 # Backwards compatiblity. Can be removed post-0.9
23 OptName = 'ACTI'
24 22
25 23 def option_name
26 24 OptionName
@@ -160,17 +160,17 module Redmine
160 160 }
161 161
162 162 # Enumerations
163 DocumentCategory.create!(:opt => "DCAT", :name => l(:default_doc_category_user), :position => 1)
164 DocumentCategory.create!(:opt => "DCAT", :name => l(:default_doc_category_tech), :position => 2)
163 DocumentCategory.create!(:name => l(:default_doc_category_user), :position => 1)
164 DocumentCategory.create!(:name => l(:default_doc_category_tech), :position => 2)
165 165
166 IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_low), :position => 1)
167 IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_normal), :position => 2, :is_default => true)
168 IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_high), :position => 3)
169 IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_urgent), :position => 4)
170 IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_immediate), :position => 5)
166 IssuePriority.create!(:name => l(:default_priority_low), :position => 1)
167 IssuePriority.create!(:name => l(:default_priority_normal), :position => 2, :is_default => true)
168 IssuePriority.create!(:name => l(:default_priority_high), :position => 3)
169 IssuePriority.create!(:name => l(:default_priority_urgent), :position => 4)
170 IssuePriority.create!(:name => l(:default_priority_immediate), :position => 5)
171 171
172 TimeEntryActivity.create!(:opt => "ACTI", :name => l(:default_activity_design), :position => 1)
173 TimeEntryActivity.create!(:opt => "ACTI", :name => l(:default_activity_development), :position => 2)
172 TimeEntryActivity.create!(:name => l(:default_activity_design), :position => 1)
173 TimeEntryActivity.create!(:name => l(:default_activity_development), :position => 2)
174 174 end
175 175 true
176 176 end
@@ -40,7 +40,7 task :migrate_from_mantis => :environment do
40 40 90 => closed_status # closed
41 41 }
42 42
43 priorities = Enumeration.priorities
43 priorities = IssuePriority.all
44 44 DEFAULT_PRIORITY = priorities[2]
45 45 PRIORITY_MAPPING = {10 => priorities[1], # none
46 46 20 => priorities[1], # low
@@ -37,7 +37,7 namespace :redmine do
37 37 'closed' => closed_status
38 38 }
39 39
40 priorities = Enumeration.priorities
40 priorities = IssuePriority.all
41 41 DEFAULT_PRIORITY = priorities[0]
42 42 PRIORITY_MAPPING = {'lowest' => priorities[0],
43 43 'low' => priorities[0],
@@ -2,63 +2,53
2 2 enumerations_001:
3 3 name: Uncategorized
4 4 id: 1
5 opt: DCAT
6 5 type: DocumentCategory
7 6 active: true
8 7 enumerations_002:
9 8 name: User documentation
10 9 id: 2
11 opt: DCAT
12 10 type: DocumentCategory
13 11 active: true
14 12 enumerations_003:
15 13 name: Technical documentation
16 14 id: 3
17 opt: DCAT
18 15 type: DocumentCategory
19 16 active: true
20 17 enumerations_004:
21 18 name: Low
22 19 id: 4
23 opt: IPRI
24 20 type: IssuePriority
25 21 active: true
26 22 enumerations_005:
27 23 name: Normal
28 24 id: 5
29 opt: IPRI
30 25 type: IssuePriority
31 26 is_default: true
32 27 active: true
33 28 enumerations_006:
34 29 name: High
35 30 id: 6
36 opt: IPRI
37 31 type: IssuePriority
38 32 active: true
39 33 enumerations_007:
40 34 name: Urgent
41 35 id: 7
42 opt: IPRI
43 36 type: IssuePriority
44 37 active: true
45 38 enumerations_008:
46 39 name: Immediate
47 40 id: 8
48 opt: IPRI
49 41 type: IssuePriority
50 42 active: true
51 43 enumerations_009:
52 44 name: Design
53 45 id: 9
54 opt: ACTI
55 46 type: TimeEntryActivity
56 47 position: 1
57 48 active: true
58 49 enumerations_010:
59 50 name: Development
60 51 id: 10
61 opt: ACTI
62 52 type: TimeEntryActivity
63 53 position: 2
64 54 is_default: true
@@ -66,27 +56,23 enumerations_010:
66 56 enumerations_011:
67 57 name: QA
68 58 id: 11
69 opt: ACTI
70 59 type: TimeEntryActivity
71 60 position: 3
72 61 active: true
73 62 enumerations_012:
74 63 name: Default Enumeration
75 64 id: 12
76 opt: ''
77 65 type: Enumeration
78 66 is_default: true
79 67 active: true
80 68 enumerations_013:
81 69 name: Another Enumeration
82 70 id: 13
83 opt: ''
84 71 type: Enumeration
85 72 active: true
86 73 enumerations_014:
87 74 name: Inactive Activity
88 75 id: 14
89 opt: ACTI
90 76 type: TimeEntryActivity
91 77 position: 4
92 78 active: false
General Comments 0
You need to be logged in to leave comments. Login now