Project

General

Profile

« Previous | Next » 

Revision 1728

Quote ids for attachment association since Trac's attachment.id is varchar (#1759).

View differences:

trunk/lib/tasks/migrate_from_trac.rake
149 149
        
150 150
        # ticket changes: only migrate status changes and comments
151 151
        has_many :changes, :class_name => "TracTicketChange", :foreign_key => :ticket
152
        has_many :attachments, :class_name => "TracAttachment", :foreign_key => :id, :conditions => "#{TracMigrate::TracAttachment.table_name}.type = 'ticket'"
152
        has_many :attachments, :class_name => "TracAttachment",
153
                               :finder_sql => "SELECT DISTINCT attachment.* FROM #{TracMigrate::TracAttachment.table_name}" +
154
                                              " WHERE #{TracMigrate::TracAttachment.table_name}.type = 'ticket'" +
155
                                              ' AND #{TracMigrate::TracAttachment.table_name}.id = \'#{id}\''
153 156
        has_many :customs, :class_name => "TracTicketCustom", :foreign_key => :ticket
154 157
        
155 158
        def ticket_type
......
186 189
        set_table_name :wiki
187 190
        set_primary_key :name
188 191
        
189
        has_many :attachments, :class_name => "TracAttachment", :foreign_key => :id, :conditions => "#{TracMigrate::TracAttachment.table_name}.type = 'wiki'"
192
        has_many :attachments, :class_name => "TracAttachment",
193
                               :finder_sql => "SELECT DISTINCT attachment.* FROM #{TracMigrate::TracAttachment.table_name}" +
194
                                      " WHERE #{TracMigrate::TracAttachment.table_name}.type = 'wiki'" +
195
                                      ' AND #{TracMigrate::TracAttachment.table_name}.id = \'#{id}\''
190 196
        
191 197
        def self.columns
192 198
          # Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0)

Also available in: Unified diff