Skip to content
Snippets Groups Projects
Verified Commit a60129d2 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Make unique constraints on break and lessonsubstitution less tight

Together with 18544e06, updating the existing
migration is safe, because

 a) if the migration failed somewhere due to the multiple leaf nodes, it was
    never applied, and changing it is safe;
 b) if it succeeded, it will be renamed to 0008_ later, and thus
    re-applied
parent e93d8b71
No related branches found
No related tags found
No related merge requests found
Pipeline #15413 passed
......@@ -14,6 +14,7 @@ Fixed
* Fix migration names and dependencies
* Migration path was ambigious
* Unique constraints for breaks and substitutions were too tight
`2.0b0`_ - 2021-05-21
---------------------
......
......@@ -52,11 +52,11 @@ class Migration(migrations.Migration):
),
migrations.AddConstraint(
model_name='break',
constraint=models.UniqueConstraint(fields=('site_id', 'short_name'), name='unique_short_name_per_site_break'),
constraint=models.UniqueConstraint(fields=('validity', 'short_name'), name='unique_short_name_per_site_break'),
),
migrations.AddConstraint(
model_name='lessonsubstitution',
constraint=models.UniqueConstraint(fields=('lesson_period', 'week'), name='unique_period_per_week'),
constraint=models.UniqueConstraint(fields=('lesson_period', 'week', 'year'), name='unique_period_per_week'),
),
migrations.AddConstraint(
model_name='room',
......
......@@ -451,7 +451,7 @@ class LessonSubstitution(ExtensibleModel, TeacherPropertiesMixin, WeekRelatedMix
),
# Heads up: Link to period implies uniqueness per site
models.UniqueConstraint(
fields=["lesson_period", "week"], name="unique_period_per_week"
fields=["lesson_period", "week", "year"], name="unique_period_per_week"
),
]
indexes = [
......@@ -866,7 +866,7 @@ class Break(ValidityRangeRelatedExtensibleModel):
verbose_name_plural = _("Breaks")
constraints = [
models.UniqueConstraint(
fields=["site_id", "short_name"], name="unique_short_name_per_site_break"
fields=["validity", "short_name"], name="unique_short_name_per_site_break"
),
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment