-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1366 from Amsterdam-Music-Lab/bugfix-er/make-expe…
…riment-slug-unique Bugfix er/make experiment slug unique
- Loading branch information
Showing
4 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
backend/experiment/migrations/0060_experiment_slug_temp.py
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,19 @@ | ||
# Generated by Django 4.2.16 on 2024-11-15 09:00 | ||
|
||
from django.db import migrations, models | ||
import experiment.validators | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('experiment', '0059_add_social_media_config'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='experiment', | ||
name='slug_temp', | ||
field=models.SlugField(null=True, max_length=64, unique=True, validators=[experiment.validators.block_slug_validator]), | ||
), | ||
] |
26 changes: 26 additions & 0 deletions
26
backend/experiment/migrations/0061_migrate_slugs_to_unique_temp_field.py
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,26 @@ | ||
# Generated by Django 4.2.16 on 2024-11-15 09:01 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
def forwards_func(apps, schema_editor): | ||
Experiment = apps.get_model('experiment', 'Experiment') | ||
for experiment in Experiment.objects.all(): | ||
experiment.slug_temp = experiment.slug | ||
experiment.save() | ||
|
||
def reverse_func(apps, schema_editor): | ||
Experiment = apps.get_model('experiment', 'Experiment') | ||
for experiment in Experiment.objects.all(): | ||
experiment.slug = experiment.slug_temp | ||
experiment.save() | ||
|
||
dependencies = [ | ||
('experiment', '0060_experiment_slug_temp'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forwards_func, reverse_func), | ||
] |
27 changes: 27 additions & 0 deletions
27
backend/experiment/migrations/0062_rename_slug_temp_to_slug.py
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,27 @@ | ||
# Generated by Django 4.2.16 on 2024-11-15 09:09 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('experiment', '0061_migrate_slugs_to_unique_temp_field'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='Experiment', | ||
old_name='slug', | ||
new_name='old_slug' | ||
), | ||
migrations.RenameField( | ||
model_name='Experiment', | ||
old_name='slug_temp', | ||
new_name='slug' | ||
), | ||
migrations.RemoveField( | ||
model_name='Experiment', | ||
name='old_slug', | ||
), | ||
] |
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