2011-10-29 16:19:11 +04:00
|
|
|
#-- encoding: UTF-8
|
2011-05-30 00:11:52 +04:00
|
|
|
#-- copyright
|
|
|
|
# ChiliProject is a project management system.
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# Copyright (C) 2010-2011 the ChiliProject Team
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# See doc/COPYRIGHT.rdoc for more details.
|
|
|
|
#++
|
|
|
|
|
2006-11-28 01:31:14 +03:00
|
|
|
class CreateJournals < ActiveRecord::Migration
|
|
|
|
|
|
|
|
# model removed, but needed for data migration
|
|
|
|
class IssueHistory < ActiveRecord::Base; belongs_to :issue; end
|
2007-08-29 20:52:35 +04:00
|
|
|
# model removed
|
|
|
|
class Permission < ActiveRecord::Base; end
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2006-11-28 01:31:14 +03:00
|
|
|
def self.up
|
|
|
|
create_table :journals, :force => true do |t|
|
|
|
|
t.column "journalized_id", :integer, :default => 0, :null => false
|
|
|
|
t.column "journalized_type", :string, :limit => 30, :default => "", :null => false
|
|
|
|
t.column "user_id", :integer, :default => 0, :null => false
|
|
|
|
t.column "notes", :text
|
|
|
|
t.column "created_on", :datetime, :null => false
|
|
|
|
end
|
|
|
|
create_table :journal_details, :force => true do |t|
|
|
|
|
t.column "journal_id", :integer, :default => 0, :null => false
|
|
|
|
t.column "property", :string, :limit => 30, :default => "", :null => false
|
|
|
|
t.column "prop_key", :string, :limit => 30, :default => "", :null => false
|
|
|
|
t.column "old_value", :string
|
|
|
|
t.column "value", :string
|
|
|
|
end
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2006-11-28 01:31:14 +03:00
|
|
|
# indexes
|
|
|
|
add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id"
|
|
|
|
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2006-11-28 01:31:14 +03:00
|
|
|
Permission.create :controller => "issues", :action => "history", :description => "label_history", :sort => 1006, :is_public => true, :mail_option => 0, :mail_enabled => 0
|
|
|
|
|
|
|
|
# data migration
|
|
|
|
IssueHistory.find(:all, :include => :issue).each {|h|
|
|
|
|
j = Journal.new(:journalized => h.issue, :user_id => h.author_id, :notes => h.notes, :created_on => h.created_on)
|
|
|
|
j.details << JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :value => h.status_id)
|
2011-05-30 22:52:25 +04:00
|
|
|
j.save
|
|
|
|
}
|
2006-11-28 01:31:14 +03:00
|
|
|
|
|
|
|
drop_table :issue_histories
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
drop_table :journal_details
|
|
|
|
drop_table :journals
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2006-11-28 01:31:14 +03:00
|
|
|
create_table "issue_histories", :force => true do |t|
|
|
|
|
t.column "issue_id", :integer, :default => 0, :null => false
|
|
|
|
t.column "status_id", :integer, :default => 0, :null => false
|
|
|
|
t.column "author_id", :integer, :default => 0, :null => false
|
|
|
|
t.column "notes", :text, :default => ""
|
|
|
|
t.column "created_on", :timestamp
|
|
|
|
end
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2006-11-28 01:31:14 +03:00
|
|
|
add_index "issue_histories", ["issue_id"], :name => "issue_histories_issue_id"
|
|
|
|
|
|
|
|
Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'history']).destroy
|
|
|
|
end
|
|
|
|
end
|