-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#2564] Mark catalogus as a required field on ZaakTypeconfig
This field was only optional because eSuite did not (always) include a catalogus on its zaak types. That has since been fixed. This commit removes some legacy behavior which assumes that catalogus is nullable.
- Loading branch information
1 parent
cf03b3d
commit ef78f3c
Showing
6 changed files
with
106 additions
and
159 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
55 changes: 55 additions & 0 deletions
55
src/open_inwoner/openzaak/migrations/0052_zaaktypeconfig_catalogus_is_required.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,55 @@ | ||
# Generated by Django 4.2.11 on 2024-06-18 12:04 | ||
|
||
from django.db import DataError, migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
def validate_no_missing_catalogus_fields(apps, schema_editor): | ||
ZaakTypeConfig = apps.get_model("openzaak", "ZaakTypeConfig") | ||
|
||
if rows_with_missing_catalogus := ZaakTypeConfig.objects.filter( | ||
catalogus__isnull=True | ||
).count(): | ||
raise DataError( | ||
f"Your database contains {rows_with_missing_catalogus} ZaakTypeConfig" | ||
" row(s) with a missing `catalogus` field. This field is now required:" | ||
" please manually update all the affected rows or re-sync your ZGW" | ||
" objects to ensure the field is included." | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("openzaak", "0051_drop_root_zgw_fields"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
validate_no_missing_catalogus_fields, | ||
reverse_code=lambda *args, **kwargs: None, | ||
), | ||
migrations.AlterField( | ||
model_name="zaaktypeconfig", | ||
name="catalogus", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="openzaak.catalogusconfig", | ||
), | ||
), | ||
migrations.RemoveConstraint( | ||
model_name="zaaktypeconfig", | ||
name="unique_identificatie_in_catalogus", | ||
), | ||
migrations.RemoveConstraint( | ||
model_name="zaaktypeconfig", | ||
name="unique_identificatie_without_catalogus", | ||
), | ||
migrations.AddConstraint( | ||
model_name="zaaktypeconfig", | ||
constraint=models.UniqueConstraint( | ||
fields=("catalogus", "identificatie"), | ||
name="unique_identificatie_in_catalogus", | ||
), | ||
), | ||
] |
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
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
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
Oops, something went wrong.