Sha256: bb559dcfa0feeb8d102c01e125f2a8f869f91709505d48c1d8d20807bcfabd07

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

class CreateEchiAcds < ActiveRecord::Migration
  def self.up
    #We create the table from the one defined in the application.yml file
    create_table "echi_acds", :force => true do |t|
      @@echi_schema["echi_acds"].each do | field |
        case field["type"]
        when 'int'
          if ActiveRecord::Base.connection.adapter_name == 'Oracle'
            case field["length"]
            when 4
              oracle_precision = 10
            when 2
              oracle_precision = 5
            when 1
              oracle_precision = 3
            end
            t.column field["name"], :integer, :limit => oracle_precision, :precision => oracle_precision, :scale => 0
          else
            t.column field["name"], :integer, :limit => field["length"], :precision => field["length"], :scale => 0
          end
        when 'str'
          t.column field["name"], :string, :limit => field["length"]
        when 'datetime'
          t.column field["name"], :datetime
        when 'bool'
          t.column field["name"], :string, :limit => 1
        when 'boolint'
          t.column field["name"], :string, :limit => 1
        end
      end
    end
    add_index "echi_acds", "acd_id"
  end

  def self.down
    remove_index "echi_acds", "acd_id"
    drop_table "echi_acds"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
echi-converter-0.4.4 db/migrate/009_create_echi_acds.rb
echi-converter-0.4.0 db/migrate/009_create_echi_acds.rb
echi-converter-0.4.1 db/migrate/009_create_echi_acds.rb
echi-converter-0.4.2 db/migrate/009_create_echi_acds.rb