Add foreign names to the database.
[zzz-pokedex.git] / pokedex / db / tables.py
index 1dacc80..e6a7b77 100644 (file)
@@ -254,6 +254,12 @@ class ItemInternalID(TableBase):
     generation_id = Column(Integer, ForeignKey('generations.id'), primary_key=True, autoincrement=False, nullable=False)
     internal_id = Column(Integer, nullable=False)
 
+class ItemName(TableBase):
+    __tablename__ = 'item_names'
+    item_id = Column(Integer, ForeignKey('items.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 ItemPocket(TableBase):
     __tablename__ = 'item_pockets'
     id = Column(Integer, primary_key=True, nullable=False)
@@ -393,6 +399,12 @@ class NatureBattleStylePreference(TableBase):
     low_hp_preference = Column(Integer, nullable=False)
     high_hp_preference = Column(Integer, nullable=False)
 
+class NatureName(TableBase):
+    __tablename__ = 'nature_names'
+    nature_id = Column(Integer, ForeignKey('natures.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(8), nullable=False)
+
 class NaturePokeathlonStat(TableBase):
     __tablename__ = 'nature_pokeathlon_stats'
     nature_id = Column(Integer, ForeignKey('natures.id'), primary_key=True, nullable=False)
@@ -741,6 +753,7 @@ Item.berry = relation(Berry, uselist=False, backref='item')
 Item.flags = relation(ItemFlag, secondary=ItemFlagMap.__table__)
 Item.flavor_text = relation(ItemFlavorText, order_by=ItemFlavorText.version_group_id.asc(), backref='item')
 Item.fling_effect = relation(ItemFlingEffect, backref='items')
+Item.foreign_names = relation(ItemName, backref='item')
 Item.machines = relation(Machine, order_by=Machine.version_group_id.asc())
 Item.category = relation(ItemCategory)
 Item.pocket = association_proxy('category', 'pocket')
@@ -750,6 +763,8 @@ ItemCategory.pocket = relation(ItemPocket)
 
 ItemFlavorText.version_group = relation(VersionGroup)
 
+ItemName.language = relation(Language)
+
 ItemPocket.categories = relation(ItemCategory, order_by=ItemCategory.name)
 
 Location.region = relation(Region, backref='locations')
@@ -791,6 +806,7 @@ MoveFlavorText.version_group = relation(VersionGroup)
 
 MoveName.language = relation(Language)
 
+Nature.foreign_names = relation(NatureName, backref='nature')
 Nature.decreased_stat = relation(Stat, primaryjoin=Nature.decreased_stat_id==Stat.id,
                                        backref='decreasing_natures')
 Nature.increased_stat = relation(Stat, primaryjoin=Nature.increased_stat_id==Stat.id,
@@ -806,6 +822,8 @@ Nature.pokeathlon_effects = relation(NaturePokeathlonStat, order_by=NaturePokeat
 
 NatureBattleStylePreference.battle_style = relation(MoveBattleStyle, backref='nature_preferences')
 
+NatureName.language = relation(Language)
+
 NaturePokeathlonStat.pokeathlon_stat = relation(PokeathlonStat, backref='nature_effects')
 
 Pokedex.region = relation(Region, backref='pokedexes')