Skip to content
Snippets Groups Projects
Verified Commit a44e59f0 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 fe17ca89
No related branches found
No related tags found
1 merge request!175Resolve "Unique constraints doesn't include all necessary fields"
Pipeline #15390 passed
Changelog
=========
Unreleased
----------
Fixed
~~~~~
* 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