-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
model: add migration to replace meeting primary key
- Loading branch information
1 parent
382d939
commit 97dc124
Showing
6 changed files
with
164 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 3.2.23 on 2024-05-24 13:22 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('rest', '0016_resize_meeting_name_length'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameModel( | ||
old_name='Meeting', | ||
new_name='MeetingOld', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Generated by Django 3.2.23 on 2024-05-24 13:29 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
import rest.models | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('rest', '0017_rename_meeting_meetingold'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='MeetingNew', | ||
fields=[ | ||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)), | ||
('id', models.CharField(max_length=100)), | ||
('room_name', models.CharField(max_length=256)), | ||
('age', models.DateTimeField(default=django.utils.timezone.now)), | ||
('attendees', models.SmallIntegerField(default=0)), | ||
('end_callback_url', models.URLField(default='')), | ||
('listenerCount', models.SmallIntegerField(default=0)), | ||
('nonce', models.CharField(default=rest.models.get_nonce, editable=False, max_length=64, unique=True)), | ||
('voiceParticipantCount', models.SmallIntegerField(default=0)), | ||
('moderatorCount', models.SmallIntegerField(default=0)), | ||
('videoCount', models.SmallIntegerField(default=0)), | ||
('bbb_origin', models.CharField(default='', max_length=255)), | ||
('bbb_origin_server_name', models.CharField(default='', max_length=255)), | ||
('node', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rest.node')), | ||
('secret', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rest.secret')), | ||
], | ||
options={ | ||
'ordering': ['secret__tenant', 'age'], | ||
}, | ||
), | ||
migrations.AddConstraint( | ||
model_name='meetingnew', | ||
constraint=models.UniqueConstraint(fields=('id', 'secret'), name='unique_meeting'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by Django 3.2.23 on 2024-05-24 13:29 | ||
|
||
from django.db import migrations | ||
|
||
def migrate_meetings(apps, schema_editor): | ||
meeting_class = apps.get_model("rest", "MeetingNew") | ||
meeting_old_class = apps.get_model("rest", "MeetingOld") | ||
for meeting_old in meeting_old_class.objects.all(): | ||
meeting = meeting_class() | ||
meeting.id = meeting_old.id | ||
meeting.secret = meeting_old.secret | ||
meeting.node = meeting_old.node | ||
meeting.room_name = meeting_old.room_name | ||
meeting.age = meeting_old.age | ||
meeting.attendees = meeting_old.attendees | ||
meeting.end_callback_url = meeting_old.end_callback_url | ||
meeting.listenerCount = meeting_old.listenerCount | ||
meeting.nonce = meeting_old.nonce | ||
meeting.voiceParticipantCount = meeting_old.voiceParticipantCount | ||
meeting.moderatorCount = meeting_old.moderatorCount | ||
meeting.videoCount = meeting_old.videoCount | ||
meeting.bbb_origin = meeting_old.bbb_origin | ||
meeting.bbb_origin_server_name = meeting_old.bbb_origin_server_name | ||
meeting.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('rest', '0018_meeting'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(migrate_meetings) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generated by Django 3.2.23 on 2024-05-24 13:46 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
def migrate_record_set_meetings(apps, schema_editor): | ||
record_set_class = apps.get_model('rest', 'RecordSet') | ||
for record_set in record_set_class.objects.all(): | ||
if record_set.meeting: | ||
record_set.meeting = None | ||
record_set.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('rest', '0019_migrate_meeting_data'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(migrate_record_set_meetings), | ||
migrations.AlterField( | ||
model_name='recordset', | ||
name='meeting', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='rest.meetingnew'), | ||
), | ||
migrations.DeleteModel( | ||
name='MeetingOld', | ||
), | ||
migrations.RenameModel( | ||
old_name='MeetingNew', | ||
new_name='Meeting', | ||
), | ||
migrations.AlterField( | ||
model_name='recordset', | ||
name='meeting', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='rest.meeting'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.2.23 on 2024-05-24 14:14 | ||
|
||
from django.db import migrations | ||
|
||
def refill_record_set(apps, schema_editor): | ||
record_set_class = apps.get_model('rest', 'RecordSet') | ||
meeting_class = apps.get_model('rest', 'Meeting') | ||
for record_set in record_set_class.objects.all(): | ||
if record_set.status == "UNKNOWN" and record_set.meta_meeting_id: | ||
meetings = meeting_class.objects.filter(id=record_set.meta_meeting_id, secret=record_set.secret) | ||
if meetings.count() == 1: | ||
record_set.meeting = meetings[0] | ||
record_set.save() | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('rest', '0020_remove_meetingold'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(refill_record_set) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters