about summary refs log tree commit diff stats
path: root/db/migrate/20170930021856_add_gift_ribbons_to_trainer.rb
blob: ed15ea1cca04b76a556fc446e3682664e17d4fe9 (plain) (blame)
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
class AddGiftRibbonsToTrainer < ActiveRecord::Migration[5.1]
  def change
    change_table :trainers do |t|
      t.references :marine_ribbon, null: true
      t.references :land_ribbon, null: true
      t.references :sky_ribbon, null: true
      t.references :country_ribbon, null: true
      t.references :national_ribbon, null: true
      t.references :earth_ribbon, null: true
      t.references :world_ribbon, null: true
    end

    add_foreign_key :trainers, :gift_ribbons,
      column: :marine_ribbon_id

    add_foreign_key :trainers, :gift_ribbons,
      column: :land_ribbon_id

    add_foreign_key :trainers, :gift_ribbons,
      column: :sky_ribbon_id

    add_foreign_key :trainers, :gift_ribbons,
      column: :country_ribbon_id

    add_foreign_key :trainers, :gift_ribbons,
      column: :national_ribbon_id

    add_foreign_key :trainers, :gift_ribbons,
      column: :earth_ribbon_id

    add_foreign_key :trainers, :gift_ribbons,
      column: :world_ribbon_id
  end
end