58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
from django.db import migrations, models
|
|
|
|
|
|
def create_initial_course_fallbacks(apps, schema_editor):
|
|
FallbackCurso = apps.get_model("core", "FallbackCurso")
|
|
FallbackCurso.objects.get_or_create(
|
|
texto_api="Bacharelado em Administração",
|
|
defaults={"texto_local": "ADMINISTRAÇÃO"},
|
|
)
|
|
|
|
|
|
def remove_initial_course_fallbacks(apps, schema_editor):
|
|
FallbackCurso = apps.get_model("core", "FallbackCurso")
|
|
FallbackCurso.objects.filter(
|
|
texto_api="Bacharelado em Administração",
|
|
texto_local="ADMINISTRAÇÃO",
|
|
).delete()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("core", "0008_create_ano_censo_2025"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="FallbackCurso",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.BigAutoField(
|
|
auto_created=True,
|
|
primary_key=True,
|
|
serialize=False,
|
|
verbose_name="ID",
|
|
),
|
|
),
|
|
("texto_api", models.CharField(max_length=200, unique=True)),
|
|
("texto_local", models.CharField(max_length=200)),
|
|
],
|
|
options={
|
|
"verbose_name": "fallback de curso",
|
|
"verbose_name_plural": "fallbacks de curso",
|
|
"ordering": ["texto_api"],
|
|
},
|
|
),
|
|
migrations.AddIndex(
|
|
model_name="fallbackcurso",
|
|
index=models.Index(fields=["texto_api"], name="core_fallba_texto_a_b13933_idx"),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name="fallbackcurso",
|
|
index=models.Index(fields=["texto_local"], name="core_fallba_texto_l_644724_idx"),
|
|
),
|
|
migrations.RunPython(create_initial_course_fallbacks, remove_initial_course_fallbacks),
|
|
]
|