X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/deb4e5ba672dc4c22df44cf20cfe727203bf2abc..6c6c8b413ed019a5fc2e406a9829282778792965:/pokedex/db/tables.py diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index 82159d3..8033879 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -28,6 +28,12 @@ class AbilityFlavorText(TableBase): version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False, autoincrement=False) flavor_text = Column(Unicode(64), nullable=False) +class AbilityName(TableBase): + __tablename__ = 'ability_names' + ability_id = Column(Integer, ForeignKey('abilities.id'), primary_key=True, nullable=False, autoincrement=False) + language_id = Column(Integer, ForeignKey('languages.id'), primary_key=True, nullable=False, autoincrement=False) + name = Column(Unicode(16), nullable=False) + class Berry(TableBase): __tablename__ = 'berries' id = Column(Integer, primary_key=True, nullable=False) @@ -174,12 +180,6 @@ class EvolutionChain(TableBase): steps_to_hatch = Column(Integer, nullable=False) baby_trigger_item = Column(Unicode(12)) -class EvolutionMethod(TableBase): - __tablename__ = 'evolution_methods' - id = Column(Integer, primary_key=True, nullable=False) - name = Column(Unicode(64), nullable=False) - description = Column(Unicode(255), nullable=False) - class EvolutionTrigger(TableBase): __tablename__ = 'evolution_triggers' id = Column(Integer, primary_key=True, nullable=False) @@ -660,11 +660,14 @@ class Version(TableBase): ### Relations down here, to avoid ordering problems -Ability.flavor_text = relation(AbilityFlavorText, order_by=AbilityFlavorText.version_group_id, backref='abilities') +Ability.flavor_text = relation(AbilityFlavorText, order_by=AbilityFlavorText.version_group_id, backref='ability') +Ability.foreign_names = relation(AbilityName, backref='ability') Ability.generation = relation(Generation, backref='abilities') AbilityFlavorText.version_group = relation(VersionGroup) +AbilityName.language = relation(Language) + Berry.berry_firmness = relation(BerryFirmness, backref='berries') Berry.firmness = association_proxy('berry_firmness', 'name') Berry.flavors = relation(BerryFlavor, order_by=BerryFlavor.contest_type_id, backref='berry') @@ -736,7 +739,7 @@ Move.contest_type = relation(ContestType, backref='moves') Move.damage_class = relation(MoveDamageClass, backref='moves') Move.flags = association_proxy('move_flags', 'flag') Move.flavor_text = relation(MoveFlavorText, order_by=MoveFlavorText.version_group_id, backref='move') -Move.foreign_names = relation(MoveName, backref='pokemon') +Move.foreign_names = relation(MoveName, backref='move') Move.generation = relation(Generation, backref='moves') Move.machines = relation(Machine, backref='move') Move.move_effect = relation(MoveEffect, backref='moves') @@ -800,15 +803,11 @@ 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, - secondary=PokemonEvolution.__table__, +Pokemon.child_pokemon = relation(Pokemon, primaryjoin=Pokemon.id==PokemonEvolution.from_pokemon_id, + secondary=PokemonEvolution.__table__, secondaryjoin=PokemonEvolution.to_pokemon_id==Pokemon.id, - backref=backref('evolution_parent', - remote_side=[Pokemon.id], - uselist=False, - ), + backref=backref('parent_pokemon', uselist=False), ) Pokemon.flavor_text = relation(PokemonFlavorText, order_by=PokemonFlavorText.version_id.asc(), backref='pokemon') Pokemon.foreign_names = relation(PokemonName, backref='pokemon')