mattman (owner)

Fork Of

Revisions

gist: 115314 Download_button fork
public
Public Clone URL: git://gist.github.com/115314.git
Embed All Files: show embed
migrater.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class LegacyBase < ActiveRecord::Base
  establish_connection(
    :adapter => "mysql",
    :host => "localhost",
    :username => "",
    :password => "",
    :database => "ws_prosecutions"
  )
end
 
class LegacyProsecutions < LegacyBase
  set_table_name "prosecutions"
  
  def migrate_me!
    prosecution = Prosecution.create(
      :defendant => self.Defendant,
      :section => (self.Section || '') + " -- " + (self.zSearch_sec_reg_1 || '') + " - " + (self.zSearch_sec_reg_2 || '') + " - " + (self.zSearch_sec_reg_3 || ''),
      :description => self.Description,
      :background => self.Background,
      :conviction_date => (self.Conviction\ Date || '').to_date,
      :court => self.Court,
      :fine => self.Fine,
      :outcome_summary => self.Outcome\ Summary,
      :charge_number => self.Charge_Number || '',
      :date_added => (self.Date\ Added || '').to_date,
      :regulation => self.Regulation || '',
      :offence_date => self.Offence_Date,
      :trading_name => self.Trading_Name || '',
      :inspector => self.Inspector,
      :costs => self.Costs || '',
      :file_number => self.File_Number,
      :publish => self.Publish.downcase == "yes" ? true : false,
      :image => self.Image || ''
    )
  end
end