1
0
Fork 0
mirror of https://github.com/veekun/pokedex.git synced 2024-08-20 18:16:34 +00:00

Factored habitats into a separate table.

This commit is contained in:
Eevee 2010-03-03 00:53:00 -08:00
parent 5b100b1651
commit 8280652dd2
3 changed files with 408 additions and 391 deletions
pokedex/db

View file

@ -300,7 +300,7 @@ class Pokemon(TableBase):
species = Column(Unicode(16), nullable=False)
color_id = Column(Integer, ForeignKey('pokemon_colors.id'), nullable=False)
pokemon_shape_id = Column(Integer, ForeignKey('pokemon_shapes.id'), nullable=False)
habitat = Column(Unicode(16), nullable=False)
habitat_id = Column(Integer, ForeignKey('pokemon_habitats.id'), nullable=True)
gender_rate = Column(Integer, nullable=False)
capture_rate = Column(Integer, nullable=False)
base_experience = Column(Integer, nullable=False)
@ -380,6 +380,11 @@ class PokemonFormSprite(TableBase):
introduced_in_version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False, autoincrement=False)
name = Column(Unicode(16), nullable=True)
class PokemonHabitat(TableBase):
__tablename__ = 'pokemon_habitats'
id = Column(Integer, primary_key=True, nullable=False, autoincrement=False)
name = Column(Unicode(16), nullable=False)
class PokemonItem(TableBase):
__tablename__ = 'pokemon_items'
pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
@ -569,6 +574,8 @@ Pokemon.evolution_children = relation(Pokemon, primaryjoin=Pokemon.id==Pokemon.e
remote_side=[Pokemon.id]))
Pokemon.flavor_text = relation(PokemonFlavorText, order_by=PokemonFlavorText.pokemon_id, backref='pokemon')
Pokemon.foreign_names = relation(PokemonName, backref='pokemon')
Pokemon.pokemon_habitat = relation(PokemonHabitat, backref='pokemon')
Pokemon.habitat = association_proxy('pokemon_habitat', 'name')
Pokemon.items = relation(PokemonItem)
Pokemon.generation = relation(Generation, backref='pokemon')
Pokemon.shape = relation(PokemonShape, backref='pokemon')