mirror of https://github.com/interlegis/sigi.git
Sesostris Vieira
2 years ago
4 changed files with 81 additions and 1 deletions
@ -0,0 +1,33 @@ |
|||||
|
# Generated by Django 4.1.2 on 2022-10-24 13:28 |
||||
|
|
||||
|
from django.db import migrations |
||||
|
|
||||
|
|
||||
|
def instance_names_fw(apps, schema_editor): |
||||
|
Servico = apps.get_model("servicos", "Servico") |
||||
|
seq = 0 |
||||
|
for s in Servico.objects.filter(instancia="").exclude( |
||||
|
data_desativacao=None |
||||
|
): |
||||
|
s.instancia = f"instancia-desativada-{seq}" |
||||
|
s.save() |
||||
|
seq += 1 |
||||
|
print(f"{seq} instâncias fakeadas") |
||||
|
|
||||
|
|
||||
|
def instance_names_rw(apps, schema_editor): |
||||
|
Servico = apps.get_model("servicos", "Servico") |
||||
|
Servico.objects.filter(instancia__startswith="instancia-desativada").update( |
||||
|
instancia="" |
||||
|
) |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
("servicos", "0015_nomeia_instancias"), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunPython(instance_names_fw, instance_names_rw), |
||||
|
] |
@ -0,0 +1,27 @@ |
|||||
|
# Generated by Django 4.1.2 on 2022-10-24 13:35 |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
("servicos", "0016_prepare_unique_tipo_servico_instancia_data_desativacao"), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterModelOptions( |
||||
|
name="servico", |
||||
|
options={ |
||||
|
"verbose_name": "serviço SEIT", |
||||
|
"verbose_name_plural": "serviços SEIT", |
||||
|
}, |
||||
|
), |
||||
|
migrations.AddConstraint( |
||||
|
model_name="servico", |
||||
|
constraint=models.UniqueConstraint( |
||||
|
fields=("tipo_servico", "instancia", "data_desativacao"), |
||||
|
name="unique_instance", |
||||
|
), |
||||
|
), |
||||
|
] |
Loading…
Reference in new issue