From: Zhorken Date: Sun, 5 Dec 2010 01:46:06 +0000 (-0500) Subject: Version group Pokédexes don't need their own table. X-Git-Tag: veekun-promotions/2010120701~14 X-Git-Url: http://git.veekun.com/zzz-pokedex.git/commitdiff_plain/050804469008c7632ed4350464d6630ceca420cf Version group Pokédexes don't need their own table. --- diff --git a/pokedex/data/csv/pokedex_version_groups.csv b/pokedex/data/csv/pokedex_version_groups.csv deleted file mode 100644 index 9bd59cc..0000000 --- a/pokedex/data/csv/pokedex_version_groups.csv +++ /dev/null @@ -1,12 +0,0 @@ -pokedex_id,version_group_id -2,1 -2,2 -2,7 -3,3 -3,4 -4,5 -4,6 -5,8 -6,9 -7,10 -8,11 diff --git a/pokedex/data/csv/version_groups.csv b/pokedex/data/csv/version_groups.csv index f0afc54..9c27720 100644 --- a/pokedex/data/csv/version_groups.csv +++ b/pokedex/data/csv/version_groups.csv @@ -1,12 +1,12 @@ -id,generation_id -1,1 -2,1 -3,2 -4,2 -5,3 -6,3 -7,3 -8,4 -9,4 -10,4 -11,5 +id,generation_id,pokedex_id +1,1,2 +2,1,2 +3,2,3 +4,2,3 +5,3,4 +6,3,4 +7,3,2 +8,4,5 +9,4,6 +10,4,7 +11,5,8 diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index 965cf6b..1db5898 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -771,15 +771,6 @@ class Pokedex(TableBase): description = Column(Unicode(512), info=dict(description=u"A longer description of the pokédex", format='plaintext')) -class PokedexVersionGroup(TableBase): - u"""Maps a pokédex to the version group that uses it - """ - __tablename__ = 'pokedex_version_groups' - pokedex_id = Column(Integer, ForeignKey('pokedexes.id'), primary_key=True, nullable=False, autoincrement=False, - info=dict(description=u"ID of the pokédex")) - version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False, autoincrement=False, - info=dict(description=u"ID of the version group")) - class Pokemon(TableBase): u"""A species of Pokémon. The core to this whole mess. """ @@ -1257,6 +1248,8 @@ class VersionGroup(TableBase): info=dict(description=u"A numeric ID")) generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False, info=dict(description=u"ID of the generation the games of this group belong to")) + pokedex_id = Column(Integer, ForeignKey('pokedexes.id'), nullable=False, + info=dict(description=u"ID of the regional Pokédex used in this version group.")) class VersionGroupRegion(TableBase): u"""Maps a region to a game version group that features it @@ -1423,7 +1416,7 @@ NatureName.language = relation(Language) NaturePokeathlonStat.pokeathlon_stat = relation(PokeathlonStat, backref='nature_effects') Pokedex.region = relation(Region, backref='pokedexes') -Pokedex.version_groups = relation(VersionGroup, secondary=PokedexVersionGroup.__table__, backref='pokedexes') +Pokedex.version_groups = relation(VersionGroup, order_by=VersionGroup.id, back_populates='pokedex') Pokemon.all_abilities = relation(Ability, secondary=PokemonAbility.__table__, @@ -1575,3 +1568,4 @@ Version.generation = association_proxy('version_group', 'generation') VersionGroup.generation = relation(Generation, backref='version_groups') VersionGroup.version_group_regions = relation(VersionGroupRegion, backref='version_group') VersionGroup.regions = association_proxy('version_group_regions', 'region') +VersionGroup.pokedex = relation(Pokedex, back_populates='version_groups')