Added relations for evolution.

Alternate Formes also now have NULL evolution chain ids.
This commit is contained in:
Eevee 2009-03-20 19:28:41 -04:00
parent ac325b620d
commit c4883a95f4
2 changed files with 11 additions and 7 deletions

View file

@ -494,8 +494,8 @@ id,name,forme_name,forme_base_pokemon_id,generation_id,evolution_chain_id,evolut
493,Arceus,,,4,254,,,,32,3200,Alpha,gray,8,,-1,3,255,0,,0,0,0
494,Pokemon494,,,,0,,,,0,0,,,0,,-1,3,255,0,,0,0,0
495,Pokemon495,,,,0,,,,0,0,,,0,,-1,3,255,0,,0,0,0
496,Deoxys,attack,386,,202,,,,17,608,DNA,red,12,rare,-1,3,215,0,,0,0,0
497,Deoxys,defense,386,,202,,,,17,608,DNA,red,12,rare,-1,3,215,0,,0,0,0
498,Deoxys,speed,386,,202,,,,17,608,DNA,red,12,rare,-1,3,215,0,,0,0,0
499,Wormadam,ground,413,,213,,,,5,65,Bagworm,gray,2,,8,45,159,70,,0,0,0
500,Wormadam,steel,413,,213,,,,5,65,Bagworm,gray,2,,8,45,159,70,,0,0,0
496,Deoxys,attack,386,,,,,,17,608,DNA,red,12,rare,-1,3,215,0,,0,0,0
497,Deoxys,defense,386,,,,,,17,608,DNA,red,12,rare,-1,3,215,0,,0,0,0
498,Deoxys,speed,386,,,,,,17,608,DNA,red,12,rare,-1,3,215,0,,0,0,0
499,Wormadam,ground,413,,,,,,5,65,Bagworm,gray,2,,8,45,159,70,,0,0,0
500,Wormadam,steel,413,,,,,,5,65,Bagworm,gray,2,,8,45,159,70,,0,0,0

1 id name forme_name forme_base_pokemon_id generation_id evolution_chain_id evolution_parent_pokemon_id evolution_method_id evolution_parameter height weight species color pokemon_shape_id habitat gender_rate capture_rate base_experience base_happiness gen1_internal_id is_baby has_dp_fem_sprite has_dp_fem_back_sprite
494 493 Arceus 4 254 32 3200 Alpha gray 8 -1 3 255 0 0 0 0
495 494 Pokemon494 0 0 0 0 -1 3 255 0 0 0 0
496 495 Pokemon495 0 0 0 0 -1 3 255 0 0 0 0
497 496 Deoxys attack 386 202 17 608 DNA red 12 rare -1 3 215 0 0 0 0
498 497 Deoxys defense 386 202 17 608 DNA red 12 rare -1 3 215 0 0 0 0
499 498 Deoxys speed 386 202 17 608 DNA red 12 rare -1 3 215 0 0 0 0
500 499 Wormadam ground 413 213 5 65 Bagworm gray 2 8 45 159 70 0 0 0
501 500 Wormadam steel 413 213 5 65 Bagworm gray 2 8 45 159 70 0 0 0

View file

@ -1,6 +1,6 @@
from sqlalchemy import Column, ForeignKey, MetaData, Table
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relation
from sqlalchemy.orm import backref, relation
from sqlalchemy.types import *
from sqlalchemy.databases.mysql import *
@ -93,7 +93,7 @@ class Pokemon(TableBase):
forme_name = Column(Unicode(16))
forme_base_pokemon_id = Column(Integer, ForeignKey('pokemon.id'))
generation_id = Column(Integer, ForeignKey('generations.id'))
evolution_chain_id = Column(Integer, ForeignKey('evolution_chains.id'), nullable=False)
evolution_chain_id = Column(Integer, ForeignKey('evolution_chains.id'))
evolution_parent_pokemon_id = Column(Integer, ForeignKey('pokemon.id'))
evolution_method_id = Column(Integer, ForeignKey('evolution_methods.id'))
evolution_parameter = Column(Unicode(32))
@ -199,6 +199,10 @@ Pokemon.egg_groups = relation(EggGroup, secondary=PokemonEggGroup.__table__,
order_by=PokemonEggGroup.egg_group_id,
backref='pokemon')
Pokemon.evolution_chain = relation(EvolutionChain, backref='pokemon')
Pokemon.evolution_method = relation(EvolutionMethod)
Pokemon.evolution_children = relation(Pokemon, primaryjoin=Pokemon.id==Pokemon.evolution_parent_pokemon_id,
backref=backref('evolution_parent',
remote_side=[Pokemon.id]))
Pokemon.flavor_text = relation(PokemonFlavorText, backref='pokemon')
Pokemon.foreign_names = relation(PokemonName, backref='pokemon')
Pokemon.generation = relation(Generation, backref='pokemon')