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.
This commit is contained in:
Andrew Ekstedt 2018-09-29 10:53:18 -07:00
parent e6b64b8c5a
commit 59fd27c574
1 changed files with 6 additions and 1 deletions

View File

@ -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,