Mercurial > hg > soundsoftware-site
comparison .svn/pristine/de/deb332748ae5865ff56ca20b49648024004688b4.svn-base @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 class CreateJournals < ActiveRecord::Migration | |
2 | |
3 # model removed, but needed for data migration | |
4 class IssueHistory < ActiveRecord::Base; belongs_to :issue; end | |
5 # model removed | |
6 class Permission < ActiveRecord::Base; end | |
7 | |
8 def self.up | |
9 create_table :journals, :force => true do |t| | |
10 t.column "journalized_id", :integer, :default => 0, :null => false | |
11 t.column "journalized_type", :string, :limit => 30, :default => "", :null => false | |
12 t.column "user_id", :integer, :default => 0, :null => false | |
13 t.column "notes", :text | |
14 t.column "created_on", :datetime, :null => false | |
15 end | |
16 create_table :journal_details, :force => true do |t| | |
17 t.column "journal_id", :integer, :default => 0, :null => false | |
18 t.column "property", :string, :limit => 30, :default => "", :null => false | |
19 t.column "prop_key", :string, :limit => 30, :default => "", :null => false | |
20 t.column "old_value", :string | |
21 t.column "value", :string | |
22 end | |
23 | |
24 # indexes | |
25 add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" | |
26 add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" | |
27 | |
28 Permission.create :controller => "issues", :action => "history", :description => "label_history", :sort => 1006, :is_public => true, :mail_option => 0, :mail_enabled => 0 | |
29 | |
30 # data migration | |
31 IssueHistory.all.each {|h| | |
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) | |
34 j.save | |
35 } | |
36 | |
37 drop_table :issue_histories | |
38 end | |
39 | |
40 def self.down | |
41 drop_table :journal_details | |
42 drop_table :journals | |
43 | |
44 create_table "issue_histories", :force => true do |t| | |
45 t.column "issue_id", :integer, :default => 0, :null => false | |
46 t.column "status_id", :integer, :default => 0, :null => false | |
47 t.column "author_id", :integer, :default => 0, :null => false | |
48 t.column "notes", :text, :default => "" | |
49 t.column "created_on", :timestamp | |
50 end | |
51 | |
52 add_index "issue_histories", ["issue_id"], :name => "issue_histories_issue_id" | |
53 | |
54 Permission.where("controller=? and action=?", 'issues', 'history').first.destroy | |
55 end | |
56 end |