@@ -164,12 +164,12 namespace :redmine do | |||||
164 |
|
164 | |||
165 | # ticket changes: only migrate status changes and comments |
|
165 | # ticket changes: only migrate status changes and comments | |
166 | has_many :changes, :class_name => "TracTicketChange", :foreign_key => :ticket |
|
166 | has_many :changes, :class_name => "TracTicketChange", :foreign_key => :ticket | |
167 | has_many :attachments, :class_name => "TracAttachment", |
|
|||
168 | :finder_sql => "SELECT DISTINCT attachment.* FROM #{TracMigrate::TracAttachment.table_name}" + |
|
|||
169 | " WHERE #{TracMigrate::TracAttachment.table_name}.type = 'ticket'" + |
|
|||
170 | ' AND #{TracMigrate::TracAttachment.table_name}.id = \'#{TracMigrate::TracAttachment.connection.quote_string(id.to_s)}\'' |
|
|||
171 | has_many :customs, :class_name => "TracTicketCustom", :foreign_key => :ticket |
|
167 | has_many :customs, :class_name => "TracTicketCustom", :foreign_key => :ticket | |
172 |
|
168 | |||
|
169 | def attachments | |||
|
170 | TracMigrate::TracAttachment.all(:conditions => ["type = 'ticket' AND id = ?", self.id.to_s]) | |||
|
171 | end | |||
|
172 | ||||
173 | def ticket_type |
|
173 | def ticket_type | |
174 | read_attribute(:type) |
|
174 | read_attribute(:type) | |
175 | end |
|
175 | end | |
@@ -189,6 +189,11 namespace :redmine do | |||||
189 | class TracTicketChange < ActiveRecord::Base |
|
189 | class TracTicketChange < ActiveRecord::Base | |
190 | self.table_name = :ticket_change |
|
190 | self.table_name = :ticket_change | |
191 |
|
191 | |||
|
192 | def self.columns | |||
|
193 | # Hides Trac field 'field' to prevent clash with AR field_changed? method (Rails 3.0) | |||
|
194 | super.select {|column| column.name.to_s != 'field'} | |||
|
195 | end | |||
|
196 | ||||
192 | def time; Time.at(read_attribute(:time)) end |
|
197 | def time; Time.at(read_attribute(:time)) end | |
193 | end |
|
198 | end | |
194 |
|
199 | |||
@@ -204,16 +209,15 namespace :redmine do | |||||
204 | self.table_name = :wiki |
|
209 | self.table_name = :wiki | |
205 | set_primary_key :name |
|
210 | set_primary_key :name | |
206 |
|
211 | |||
207 | has_many :attachments, :class_name => "TracAttachment", |
|
|||
208 | :finder_sql => "SELECT DISTINCT attachment.* FROM #{TracMigrate::TracAttachment.table_name}" + |
|
|||
209 | " WHERE #{TracMigrate::TracAttachment.table_name}.type = 'wiki'" + |
|
|||
210 | ' AND #{TracMigrate::TracAttachment.table_name}.id = \'#{TracMigrate::TracAttachment.connection.quote_string(id.to_s)}\'' |
|
|||
211 |
|
||||
212 | def self.columns |
|
212 | def self.columns | |
213 | # Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0) |
|
213 | # Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0) | |
214 | super.select {|column| column.name.to_s != 'readonly'} |
|
214 | super.select {|column| column.name.to_s != 'readonly'} | |
215 | end |
|
215 | end | |
216 |
|
216 | |||
|
217 | def attachments | |||
|
218 | TracMigrate::TracAttachment.all(:conditions => ["type = 'wiki' AND id = ?", self.id.to_s]) | |||
|
219 | end | |||
|
220 | ||||
217 | def time; Time.at(read_attribute(:time)) end |
|
221 | def time; Time.at(read_attribute(:time)) end | |
218 | end |
|
222 | end | |
219 |
|
223 | |||
@@ -621,9 +625,9 namespace :redmine do | |||||
621 |
|
625 | |||
622 | def self.set_trac_adapter(adapter) |
|
626 | def self.set_trac_adapter(adapter) | |
623 | return false if adapter.blank? |
|
627 | return false if adapter.blank? | |
624 |
raise "Unknown adapter: #{adapter}!" unless %w( |
|
628 | raise "Unknown adapter: #{adapter}!" unless %w(sqlite3 mysql postgresql).include?(adapter) | |
625 | # If adapter is sqlite or sqlite3, make sure that trac.db exists |
|
629 | # If adapter is sqlite or sqlite3, make sure that trac.db exists | |
626 |
raise "#{trac_db_path} doesn't exist!" if %w( |
|
630 | raise "#{trac_db_path} doesn't exist!" if %w(sqlite3).include?(adapter) && !File.exist?(trac_db_path) | |
627 | @@trac_adapter = adapter |
|
631 | @@trac_adapter = adapter | |
628 | rescue Exception => e |
|
632 | rescue Exception => e | |
629 | puts e |
|
633 | puts e | |
@@ -686,8 +690,8 namespace :redmine do | |||||
686 | end |
|
690 | end | |
687 |
|
691 | |||
688 | def self.connection_params |
|
692 | def self.connection_params | |
689 | if %w(sqlite sqlite3).include?(trac_adapter) |
|
693 | if trac_adapter == 'sqlite3' | |
690 |
{:adapter => |
|
694 | {:adapter => 'sqlite3', | |
691 | :database => trac_db_path} |
|
695 | :database => trac_db_path} | |
692 | else |
|
696 | else | |
693 | {:adapter => trac_adapter, |
|
697 | {:adapter => trac_adapter, | |
@@ -746,8 +750,8 namespace :redmine do | |||||
746 | DEFAULT_PORTS = {'mysql' => 3306, 'postgresql' => 5432} |
|
750 | DEFAULT_PORTS = {'mysql' => 3306, 'postgresql' => 5432} | |
747 |
|
751 | |||
748 | prompt('Trac directory') {|directory| TracMigrate.set_trac_directory directory.strip} |
|
752 | prompt('Trac directory') {|directory| TracMigrate.set_trac_directory directory.strip} | |
749 |
prompt('Trac database adapter (sqlite |
|
753 | prompt('Trac database adapter (sqlite3, mysql2, postgresql)', :default => 'sqlite3') {|adapter| TracMigrate.set_trac_adapter adapter} | |
750 |
unless %w( |
|
754 | unless %w(sqlite3).include?(TracMigrate.trac_adapter) | |
751 | prompt('Trac database host', :default => 'localhost') {|host| TracMigrate.set_trac_db_host host} |
|
755 | prompt('Trac database host', :default => 'localhost') {|host| TracMigrate.set_trac_db_host host} | |
752 | prompt('Trac database port', :default => DEFAULT_PORTS[TracMigrate.trac_adapter]) {|port| TracMigrate.set_trac_db_port port} |
|
756 | prompt('Trac database port', :default => DEFAULT_PORTS[TracMigrate.trac_adapter]) {|port| TracMigrate.set_trac_db_port port} | |
753 | prompt('Trac database name') {|name| TracMigrate.set_trac_db_name name} |
|
757 | prompt('Trac database name') {|name| TracMigrate.set_trac_db_name name} |
General Comments 0
You need to be logged in to leave comments.
Login now