Sha256: 594c81e7c43301a07c92c5fbd7216da4cabd293ed7bfc32b2ef496501d5091b9

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

require_relative './migration_helper'

class AddUpgradedFromToSpaceShuttles < MigrationHelper.migration_base_class
  def up
    cti_recreate_views_after_change_to('SpaceShuttle') do
      add_column(:space_shuttles, :upgraded_from_id, :integer)
    end
    add_foreign_key :space_shuttles, :space_ships, :column => 'upgraded_from_id'
  end

  def down
    if Rails::VERSION::MAJOR >= 5
      remove_foreign_key :space_shuttles, :column => 'upgraded_from_id'
    else
      remove_foreign_key :space_shuttles, :space_ships, :column => 'upgraded_from_id'
    end
    cti_recreate_views_after_change_to('SpaceShuttle') do
      remove_column(:space_shuttles, :upgraded_from_id)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dbview_cti-0.2.3 spec/dummy-rails-3/db/migrate/20140411001620_add_upgraded_from_to_space_shuttles.rb