-
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.
Merge pull request #1262 from maykinmedia/tasks/2564-catalogus-requir…
…ed-on-zaaktypeconfig [#2564] Mark catalogus as a required field on ZaakTypeconfig
- Loading branch information
Showing
6 changed files
with
98 additions
and
158 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/0053_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", "0052_add_catalogusconfig_service"), | ||
] | ||
|
||
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
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