Skip to content

Commit

Permalink
Add migration for GroupMembership model
Browse files Browse the repository at this point in the history
  • Loading branch information
cc-a committed Nov 18, 2024
1 parent 231219f commit 1fb74ba
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
25 changes: 25 additions & 0 deletions imperial_coldfront_plugin/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.11 on 2024-11-18 16:50

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='GroupMembership',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('member', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='group_memberships_set', to=settings.AUTH_USER_MODEL)),
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='owned_group_memberships_set', to=settings.AUTH_USER_MODEL)),
],
),
]
14 changes: 11 additions & 3 deletions imperial_coldfront_plugin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db import models


class GroupMember(models.Model):
class GroupMembership(models.Model):
"""Membership relationship within a group, associating an owner with a member.
This model stores relationships where each instance represents an ownership
Expand All @@ -19,5 +19,13 @@ class GroupMember(models.Model):
AUTH_USER_MODEL. Deletes related memberships when the member is deleted.
"""

owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
member = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
owner = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="owned_group_memberships_set",
)
member = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="group_memberships_set",
)

0 comments on commit 1fb74ba

Please sign in to comment.