diff --git a/imperial_coldfront_plugin/migrations/0002_unixuid.py b/imperial_coldfront_plugin/migrations/0002_unixuid.py new file mode 100644 index 0000000..faac991 --- /dev/null +++ b/imperial_coldfront_plugin/migrations/0002_unixuid.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.11 on 2024-11-21 14:41 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('imperial_coldfront_plugin', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='UnixUID', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('identifier', models.IntegerField()), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='user_id', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/imperial_coldfront_plugin/models.py b/imperial_coldfront_plugin/models.py index deb78c6..9e05275 100644 --- a/imperial_coldfront_plugin/models.py +++ b/imperial_coldfront_plugin/models.py @@ -29,3 +29,24 @@ class GroupMembership(models.Model): on_delete=models.CASCADE, related_name="group_memberships_set", ) + + +class UnixUID(models.Model): + """Identity data to map a user to a unique identifier. + + This model stores a unique identifier for each user, which can be used to + identify users in external systems. The identifier is an integer value that + is unique to each user user. + + Attributes: + user (OneToOneField): A reference to the user, connected to AUTH_USER_MODEL. + Deletes the related identifier when the user is deleted. + identifier (IntegerField): A unique identifier for the user. + """ + + user = models.OneToOneField( + settings.AUTH_USER_MODEL, + on_delete=models.CASCADE, + related_name="user_id", + ) + identifier = models.IntegerField()