Skip to content

Commit

Permalink
feature: implement basic model
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienGiboire committed Oct 13, 2021
1 parent 8866bb2 commit 9bb59a1
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/pokemon.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Pokemon < ApplicationRecord
has_many :pokemon_types
has_many :types, through: :pokemon_types
end
4 changes: 4 additions & 0 deletions app/models/pokemon_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class PokemonType < ApplicationRecord
belongs_to :pokemon
belongs_to :type
end
4 changes: 4 additions & 0 deletions app/models/type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Type < ApplicationRecord
has_many :pokemon_types
has_many :pokemons, through: :pokemon_types
end
14 changes: 14 additions & 0 deletions db/migrate/20211012155732_create_pokemons.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CreatePokemons < ActiveRecord::Migration[6.1]
def change
create_table :pokemons do |t|
t.string :name
t.integer :base_experience
t.integer :height
t.boolean :is_default
t.integer :order
t.integer :weight

t.timestamps
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/20211012160110_create_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateTypes < ActiveRecord::Migration[6.1]
def change
create_table :types do |t|
t.string :name

t.timestamps
end
end
end
11 changes: 11 additions & 0 deletions db/migrate/20211012160339_create_pokemon_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreatePokemonTypes < ActiveRecord::Migration[6.1]
def change
create_table :pokemon_types do |t|
t.belongs_to :pokemon
t.belongs_to :type
t.integer :slot

t.timestamps
end
end
end
42 changes: 42 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9bb59a1

Please sign in to comment.