From 59fd27c574f66f5afc5ebb0e602f73f3fb726700 Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Sat, 29 Sep 2018 10:53:18 -0700 Subject: [PATCH] Require location identifiers to be unique. Also require location area identifiers to be unique to their location. I almost added a duplicate pokemon-league location when adding S/M locations. This should help. --- pokedex/db/tables.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index 05e5bb9..b05f9b3 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -1103,7 +1103,7 @@ class Location(TableBase): doc=u"A numeric ID") region_id = Column(Integer, ForeignKey('regions.id'), doc=u"ID of the region this location is in") - identifier = Column(Unicode(79), nullable=False, + identifier = Column(Unicode(79), nullable=False, unique=True, doc=u"An identifier", info=dict(format='identifier')) @@ -1133,6 +1133,11 @@ class LocationArea(TableBase): doc=u"An identifier", info=dict(format='identifier')) + __table_args__ = ( + UniqueConstraint(location_id, identifier), + {}, + ) + create_translation_table('location_area_prose', LocationArea, 'prose', relation_lazy='joined', name = Column(Unicode(79), nullable=True, index=True,