Sha256: d2ef1c3ecced4b0319fc647bb03da61f2d2b28fb93103dd646477d7a91a251ff

Contents?: true

Size: 457 Bytes

Versions: 5

Compression:

Stored size: 457 Bytes

Contents

class CreateSubnetDomain < ActiveRecord::Migration
  def self.up
    create_table :subnet_domains do |t|
      t.references :domain
      t.references :subnet

      t.timestamps
    end

    Subnet.unscoped.find_each do |s|
      domain = Domain.unscoped.find(s.domain_id)
      domain.subnets << s
    end
    remove_column :subnets, :domain_id
  end

  def self.down
    add_column :subnets, :domain_id, :integer
    drop_table :subnet_domains
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/db/migrate/20120110113051_create_subnet_domain.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/db/migrate/20120110113051_create_subnet_domain.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/db/migrate/20120110113051_create_subnet_domain.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/db/migrate/20120110113051_create_subnet_domain.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/db/migrate/20120110113051_create_subnet_domain.rb