X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/9a04e2a38f0a7c861933d9a7a9f6ff6b8e638b2d..78fcf39b790c65c1c387bd4147f124e3ac71fdba:/pokedex/db/tables.py?ds=sidebyside diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index 653f5af..3e58c1c 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -4,6 +4,7 @@ from sqlalchemy import Column, ForeignKey, MetaData, Table from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.orm import backref, relation +from sqlalchemy.sql import and_ from sqlalchemy.types import * from sqlalchemy.databases.mysql import * @@ -151,6 +152,7 @@ class Item(TableBase): class Language(TableBase): __tablename__ = 'languages' id = Column(Integer, primary_key=True, nullable=False) + iso3166 = Column(Unicode(2), nullable=False) name = Column(Unicode(16), nullable=False) class Location(TableBase): @@ -533,6 +535,11 @@ PokemonFormSprite.introduced_in = relation(VersionGroup) PokemonMove.pokemon = relation(Pokemon, backref='pokemon_moves') PokemonMove.version_group = relation(VersionGroup) +PokemonMove.machine = relation(Machine, backref='pokemon_moves', + primaryjoin=and_(Machine.version_group_id==PokemonMove.version_group_id, + Machine.move_id==PokemonMove.move_id), + foreign_keys=[Machine.version_group_id, Machine.move_id], + uselist=False) PokemonMove.move = relation(Move, backref='pokemon_moves') PokemonMove.method = relation(PokemonMoveMethod)