add unique constraint on name + hostmask

I'm thinking that the command to log out will be LOGOUT <name>, which
means the user hostmask must have an unambiguous link to name

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
Brian S. Stephan 2024-05-10 13:37:17 -05:00
parent ab9690fa1c
commit 34aa91ad9e
Signed by: bss
GPG Key ID: 3DE06D3180895FCB
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,17 @@
# Generated by Django 5.0.5 on 2024-05-10 18:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('idlerpg', '0001_initial'),
]
operations = [
migrations.AddConstraint(
model_name='character',
constraint=models.UniqueConstraint(models.F('name'), models.F('hostmask'), name='player_must_have_unique_character_names'),
),
]

View File

@ -121,6 +121,7 @@ class Character(models.Model):
constraints = [
models.UniqueConstraint("game", "hostmask", name="one_player_character_per_game"),
models.UniqueConstraint("game", "name", name="no_characters_with_same_name_per_game"),
models.UniqueConstraint("name", "hostmask", name="player_must_have_unique_character_names"),
]
def __str__(self):