Skip to content

Missing migration generated by Django 4  #234

@RafaPinzon93

Description

@RafaPinzon93

Checklist

  • I have verified that I am using a GIS-enabled database, such as PostGIS or Spatialite.
  • I have verified that that issue exists against the master branch of django-cities.
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • I have reduced the issue to the simplest possible case.
  • I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Steps to reproduce

When using Django >= 4, makemigrations generates a new migration, and our CI fails when checking pending migrations makemigrations --check

# Generated by Django 4.1 on 2022-11-20 12:17

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('cities', '0011_auto_20180108_0706'),
    ]

    operations = [
        migrations.AlterField(
            model_name='country',
            name='neighbours',
            field=models.ManyToManyField(to=settings.CITIES_COUNTRY_MODEL),
        ),
    ]

Proposed solutions

Django 4 made a change on the migration autodetector and generates no-op migration for some models: https://docs.djangoproject.com/en/4.1/releases/4.0/#migrations-autodetector-changes

  1. We could add this migration, but the issue with this is that those using Django < 4 will generate a new migration again.
  2. Add one no-op migration that will work for both versions, adding the related_name in neighbours = models.ManyToManyField("self", related_name='_cities_country_neighbours_+' This way it won't check for new migration in both Django versions.

Let me know which is the preferred way and if I can help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions