-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajout d'une migration assignant une fréauence de mise à jour par défa…
…ut à tous les services et modèles
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
back/dora/services/migrations/0116_assign_default_update_frequency.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.17 on 2024-12-30 15:55 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def assign_default_update_frequency(apps, schema_editor): | ||
UpdateFrequency = apps.get_model("services", "UpdateFrequency") | ||
Service = apps.get_model("services", "Service") | ||
ServiceModel = apps.get_model("services", "ServiceModel") | ||
|
||
default_update_frequency = UpdateFrequency.objects.get(value="tous-les-6-mois") | ||
|
||
Service.objects.update(update_frequency=default_update_frequency) | ||
ServiceModel.objects.update(update_frequency=default_update_frequency) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("services", "0115_updatefrequency_service_update_frequency"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
assign_default_update_frequency, reverse_code=migrations.RunPython.noop | ||
), | ||
] |