Django : make a migration run last consistently

Viewed 42

I have a migration 0042_db_views.py creating database views that currently depends on the last migration.

I want this migration 42 to always be the last one without rewriting its dependencies every time a new migration file is generated, even if we add a new migration say 0043_my_migration.py.

I have red the Django docs and a bunch of SO questions, but did not found any solution for it, there is a run_before option but not a run_after...

Is there a proper and reliable way to do it ? Something that would make dependencies=* in 0042_db_views.py for example, or an option that I did not found ?

My Django version is 4.0.5

# 0042_db_views.py
class Migration(migrations.Migration):

    dependencies = [
        ("networks", "0041_migration_41"),
    ]

    operations = [
        CreateView(
            name="My_Name",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        )
        # 8 other views are created, not detailing them here
    ]
0 Answers
Related