@@ -4,7 +4,7 class CreateJournals < ActiveRecord::Migration | |||||
4 | class IssueHistory < ActiveRecord::Base; belongs_to :issue; end |
|
4 | class IssueHistory < ActiveRecord::Base; belongs_to :issue; end | |
5 | # model removed |
|
5 | # model removed | |
6 | class Permission < ActiveRecord::Base; end |
|
6 | class Permission < ActiveRecord::Base; end | |
7 |
|
7 | |||
8 | def self.up |
|
8 | def self.up | |
9 | create_table :journals, :force => true do |t| |
|
9 | create_table :journals, :force => true do |t| | |
10 | t.column "journalized_id", :integer, :default => 0, :null => false |
|
10 | t.column "journalized_id", :integer, :default => 0, :null => false | |
@@ -20,19 +20,19 class CreateJournals < ActiveRecord::Migration | |||||
20 | t.column "old_value", :string |
|
20 | t.column "old_value", :string | |
21 | t.column "value", :string |
|
21 | t.column "value", :string | |
22 | end |
|
22 | end | |
23 |
|
23 | |||
24 | # indexes |
|
24 | # indexes | |
25 | add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" |
|
25 | add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" | |
26 | add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" |
|
26 | add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" | |
27 |
|
27 | |||
28 | Permission.create :controller => "issues", :action => "history", :description => "label_history", :sort => 1006, :is_public => true, :mail_option => 0, :mail_enabled => 0 |
|
28 | Permission.create :controller => "issues", :action => "history", :description => "label_history", :sort => 1006, :is_public => true, :mail_option => 0, :mail_enabled => 0 | |
29 |
|
29 | |||
30 | # data migration |
|
30 | # data migration | |
31 | IssueHistory.find(:all, :include => :issue).each {|h| |
|
31 | IssueHistory.find(:all, :include => :issue).each {|h| | |
32 | j = Journal.new(:journalized => h.issue, :user_id => h.author_id, :notes => h.notes, :created_on => h.created_on) |
|
32 | j = Journal.new(:journalized => h.issue, :user_id => h.author_id, :notes => h.notes, :created_on => h.created_on) | |
33 | j.details << JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :value => h.status_id) |
|
33 | j.details << JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :value => h.status_id) | |
34 |
j.save |
|
34 | j.save | |
35 |
} |
|
35 | } | |
36 |
|
36 | |||
37 | drop_table :issue_histories |
|
37 | drop_table :issue_histories | |
38 | end |
|
38 | end | |
@@ -40,7 +40,7 class CreateJournals < ActiveRecord::Migration | |||||
40 | def self.down |
|
40 | def self.down | |
41 | drop_table :journal_details |
|
41 | drop_table :journal_details | |
42 | drop_table :journals |
|
42 | drop_table :journals | |
43 |
|
43 | |||
44 | create_table "issue_histories", :force => true do |t| |
|
44 | create_table "issue_histories", :force => true do |t| | |
45 | t.column "issue_id", :integer, :default => 0, :null => false |
|
45 | t.column "issue_id", :integer, :default => 0, :null => false | |
46 | t.column "status_id", :integer, :default => 0, :null => false |
|
46 | t.column "status_id", :integer, :default => 0, :null => false | |
@@ -48,7 +48,7 class CreateJournals < ActiveRecord::Migration | |||||
48 | t.column "notes", :text, :default => "" |
|
48 | t.column "notes", :text, :default => "" | |
49 | t.column "created_on", :timestamp |
|
49 | t.column "created_on", :timestamp | |
50 | end |
|
50 | end | |
51 |
|
51 | |||
52 | add_index "issue_histories", ["issue_id"], :name => "issue_histories_issue_id" |
|
52 | add_index "issue_histories", ["issue_id"], :name => "issue_histories_issue_id" | |
53 |
|
53 | |||
54 | Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'history']).destroy |
|
54 | Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'history']).destroy |
General Comments 0
You need to be logged in to leave comments.
Login now