@@ -164,12 +164,12 namespace :redmine do | |||
|
164 | 164 | |
|
165 | 165 | # ticket changes: only migrate status changes and comments |
|
166 | 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 | 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 | 173 | def ticket_type |
|
174 | 174 | read_attribute(:type) |
|
175 | 175 | end |
@@ -189,6 +189,11 namespace :redmine do | |||
|
189 | 189 | class TracTicketChange < ActiveRecord::Base |
|
190 | 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 | 197 | def time; Time.at(read_attribute(:time)) end |
|
193 | 198 | end |
|
194 | 199 | |
@@ -204,16 +209,15 namespace :redmine do | |||
|
204 | 209 | self.table_name = :wiki |
|
205 | 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 | 212 | def self.columns |
|
213 | 213 | # Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0) |
|
214 | 214 | super.select {|column| column.name.to_s != 'readonly'} |
|
215 | 215 | end |
|
216 | 216 | |
|
217 | def attachments | |
|
218 | TracMigrate::TracAttachment.all(:conditions => ["type = 'wiki' AND id = ?", self.id.to_s]) | |
|
219 | end | |
|
220 | ||
|
217 | 221 | def time; Time.at(read_attribute(:time)) end |
|
218 | 222 | end |
|
219 | 223 | |
@@ -621,9 +625,9 namespace :redmine do | |||
|
621 | 625 | |
|
622 | 626 | def self.set_trac_adapter(adapter) |
|
623 | 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 | 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 | 631 | @@trac_adapter = adapter |
|
628 | 632 | rescue Exception => e |
|
629 | 633 | puts e |
@@ -686,8 +690,8 namespace :redmine do | |||
|
686 | 690 | end |
|
687 | 691 | |
|
688 | 692 | def self.connection_params |
|
689 | if %w(sqlite sqlite3).include?(trac_adapter) | |
|
690 |
{:adapter => |
|
|
693 | if trac_adapter == 'sqlite3' | |
|
694 | {:adapter => 'sqlite3', | |
|
691 | 695 | :database => trac_db_path} |
|
692 | 696 | else |
|
693 | 697 | {:adapter => trac_adapter, |
@@ -746,8 +750,8 namespace :redmine do | |||
|
746 | 750 | DEFAULT_PORTS = {'mysql' => 3306, 'postgresql' => 5432} |
|
747 | 751 | |
|
748 | 752 | prompt('Trac directory') {|directory| TracMigrate.set_trac_directory directory.strip} |
|
749 |
prompt('Trac database adapter (sqlite |
|
|
750 |
unless %w( |
|
|
753 | prompt('Trac database adapter (sqlite3, mysql2, postgresql)', :default => 'sqlite3') {|adapter| TracMigrate.set_trac_adapter adapter} | |
|
754 | unless %w(sqlite3).include?(TracMigrate.trac_adapter) | |
|
751 | 755 | prompt('Trac database host', :default => 'localhost') {|host| TracMigrate.set_trac_db_host host} |
|
752 | 756 | prompt('Trac database port', :default => DEFAULT_PORTS[TracMigrate.trac_adapter]) {|port| TracMigrate.set_trac_db_port port} |
|
753 | 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