about summary refs log tree commit diff stats
path: root/db/migrate/20170917011258_create_pokeviewer_revisions.rb
blob: 0528ea481628a0057619966c26867bf9445ab35b (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class CreatePokeviewerRevisions < ActiveRecord::Migration[5.1]
  def change
    create_table :revisions do |t|
      t.references :pokemon, null: false
      t.integer :sequential_id, null: false
      t.string :nickname, null: false
      t.integer :experience, null: false
      t.integer :level, null: false
      t.integer :hp, null: false
      t.integer :attack, null: false
      t.integer :defense, null: false
      t.integer :special_attack, null: false
      t.integer :special_defense, null: false
      t.integer :speed, null: false
      t.integer :coolness, null: false
      t.integer :beauty, null: false
      t.integer :cuteness, null: false
      t.integer :smartness, null: false
      t.integer :toughness, null: false
      t.integer :sheen, null: false
      t.integer :hold_item, null: true
      t.references :move_1, null: false
      t.references :move_2, null: true
      t.references :move_3, null: true
      t.references :move_4, null: true
      t.integer :move_1_pp_bonuses, null: false, default: 0
      t.integer :move_2_pp_bonuses, null: false, default: 0
      t.integer :move_3_pp_bonuses, null: false, default: 0
      t.integer :move_4_pp_bonuses, null: false, default: 0

      t.timestamps
    end

    add_index :revisions, [:pokemon_id, :sequential_id], unique: true

    add_foreign_key :revisions, :pokemon,
      column: :pokemon_id

    add_foreign_key :revisions, :moves,
      column: :move_1_id

    add_foreign_key :revisions, :moves,
      column: :move_2_id

    add_foreign_key :revisions, :moves,
      column: :move_3_id

    add_foreign_key :revisions, :moves,
      column: :move_4_id
  end
end