Factored Pokémon colors out into their own table.

This commit is contained in:
Eevee 2010-03-02 20:27:40 -08:00
parent 123def9c68
commit 5b100b1651
3 changed files with 525 additions and 507 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,11 @@
id,name
1,black
2,blue
3,brown
4,gray
5,green
6,pink
7,purple
8,red
9,white
10,yellow
1 id name
2 1 black
3 2 blue
4 3 brown
5 4 gray
6 5 green
7 6 pink
8 7 purple
9 8 red
10 9 white
11 10 yellow

View file

@ -298,7 +298,7 @@ class Pokemon(TableBase):
height = Column(Integer, nullable=False) height = Column(Integer, nullable=False)
weight = Column(Integer, nullable=False) weight = Column(Integer, nullable=False)
species = Column(Unicode(16), nullable=False) species = Column(Unicode(16), nullable=False)
color = Column(Unicode(6), nullable=False) color_id = Column(Integer, ForeignKey('pokemon_colors.id'), nullable=False)
pokemon_shape_id = Column(Integer, ForeignKey('pokemon_shapes.id'), nullable=False) pokemon_shape_id = Column(Integer, ForeignKey('pokemon_shapes.id'), nullable=False)
habitat = Column(Unicode(16), nullable=False) habitat = Column(Unicode(16), nullable=False)
gender_rate = Column(Integer, nullable=False) gender_rate = Column(Integer, nullable=False)
@ -346,6 +346,11 @@ class PokemonAbility(TableBase):
ability_id = Column(Integer, ForeignKey('abilities.id'), nullable=False) ability_id = Column(Integer, ForeignKey('abilities.id'), nullable=False)
slot = Column(Integer, primary_key=True, nullable=False, autoincrement=False) slot = Column(Integer, primary_key=True, nullable=False, autoincrement=False)
class PokemonColor(TableBase):
__tablename__ = 'pokemon_colors'
id = Column(Integer, primary_key=True, nullable=False, autoincrement=False)
name = Column(Unicode(6), nullable=False)
class PokemonDexNumber(TableBase): class PokemonDexNumber(TableBase):
__tablename__ = 'pokemon_dex_numbers' __tablename__ = 'pokemon_dex_numbers'
pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False) pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
@ -551,6 +556,8 @@ Pokemon.abilities = relation(Ability, secondary=PokemonAbility.__table__,
Pokemon.formes = relation(Pokemon, primaryjoin=Pokemon.id==Pokemon.forme_base_pokemon_id, Pokemon.formes = relation(Pokemon, primaryjoin=Pokemon.id==Pokemon.forme_base_pokemon_id,
backref=backref('forme_base_pokemon', backref=backref('forme_base_pokemon',
remote_side=[Pokemon.id])) remote_side=[Pokemon.id]))
Pokemon.pokemon_color = relation(PokemonColor, backref='pokemon')
Pokemon.color = association_proxy('pokemon_color', 'name')
Pokemon.dex_numbers = relation(PokemonDexNumber, backref='pokemon') Pokemon.dex_numbers = relation(PokemonDexNumber, backref='pokemon')
Pokemon.egg_groups = relation(EggGroup, secondary=PokemonEggGroup.__table__, Pokemon.egg_groups = relation(EggGroup, secondary=PokemonEggGroup.__table__,
order_by=PokemonEggGroup.egg_group_id, order_by=PokemonEggGroup.egg_group_id,