Sha256: eaee1723c8f89fe7cb2535b17ebe1a77348babcf36f9fc5301631631f879941d

Contents?: true

Size: 536 Bytes

Versions: 5

Compression:

Stored size: 536 Bytes

Contents

class AddToolConstraint < ActiveRecord::Migration
  def change
    BitCore::Tool.all.each do |t|
      t.destroy! if t.arm.nil?
    end

    reversible do |dir|
      dir.up do
        execute <<-SQL
          ALTER TABLE bit_core_tools
            ADD CONSTRAINT fk_tools_arms
            FOREIGN KEY (arm_id)
            REFERENCES arms(id)
        SQL
      end

      dir.down do
        execute <<-SQL
          ALTER TABLE bit_core_tools
            DROP CONSTRAINT IF EXISTS fk_tools_arms
        SQL
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bit_core-1.4.7 db/migrate/20150210161229_add_tool_constraint.rb
bit_core-2.0.0.beta2 db/migrate/20150210161229_add_tool_constraint.rb
bit_core-2.0.0.beta1 db/migrate/20150210161229_add_tool_constraint.rb
bit_core-1.4.6 db/migrate/20150210161229_add_tool_constraint.rb
bit_core-1.4.5 db/migrate/20150210161229_add_tool_constraint.rb