Git Product home page Git Product logo

Comments (16)

furious-luke avatar furious-luke commented on July 2, 2024 1

Actually, scratch that, after thinking a little more about it it makes sense that you'd get an error in certain circumstances. I believe the error occurs as a result of the workflow I mentioned before, and I think the reason the newly created migration in Django Address gets deleted is due most likely to reinstalling the dependencies/virtual environment.

I'll raise a PR to correct the issue and link to this issue. Thanks @daniel-butler!

from django-address.

daniel-butler avatar daniel-butler commented on July 2, 2024

I honestly don't know how I got that migration number. When I looked through the current develop branch and the one tag with the version number I found the latest migration to be 0003_auto_20200830_1851 when I updated the migration to use that file it worked.

https://github.com/furious-luke/django-address/tree/develop/address/migrations

from django-address.

furious-luke avatar furious-luke commented on July 2, 2024

Hi @daniel-butler! That sounds pretty frustrating. If you were to start a new project do you still get the same error? One thing to check might be that your database is empty before trying again. Django stores details about which migrations have been run, it could be conceivable that it's getting confused by bogus data in the migration table (however that's just a guess).

Please let me know if you're still experiencing issues, we'll dig into it.

from django-address.

daniel-butler avatar daniel-butler commented on July 2, 2024

It happened again when I recreated the migrations. It is possible I am doing something wrong, though.

from django-address.

sacovo avatar sacovo commented on July 2, 2024

Could this be the issue?
https://stackoverflow.com/questions/67006488/migrating-models-of-dependencies-when-changing-default-auto-field

from django-address.

daniel-butler avatar daniel-butler commented on July 2, 2024

I think that is it. I'll try it tomorrow!

from django-address.

daniel-butler avatar daniel-butler commented on July 2, 2024

That was the issue! This was the fix

settings.py

INSTALLED_APPS = [
    ...
    "project.apps.ModifiedAddressConfig",
    ...
]

project/apps.py

"""
Defines app configurations for dependency files to avoid unnecessary migrations

More details: https://stackoverflow.com/a/67007098/7838574
"""
from address.apps import AddressConfig


class ModifiedAddressConfig(AddressConfig):
    default_auto_field = "django.db.models.AutoField"

from django-address.

furious-luke avatar furious-luke commented on July 2, 2024

Hey @daniel-butler! That certainly explains why you're getting an additional migration created within Django Address, however it's not clear to me that this explains why there is a non-existant parent migration file, which I think is the more pressing concern.

I've created the same situation locally (i.e. I've set DEFAULT_AUTO_FIELD to BigAutoField instead of AutoField) and can cause Django to trigger creating a new migration, however it also migrates correctly:

image

So, it seems that for some reason the generated migration file in your setup is getting removed. Can you think of a reason why that might be happening?

from django-address.

daniel-butler avatar daniel-butler commented on July 2, 2024

Yeah, I think, it is because I added Django-address after I had a few migrations in the project. When creating the new migration with addresses is when I ran into the issue of have a non-existing migration being a parent of another.

Thinking about it, I would expect to continue to run into the problem, but it only happened once.

Does that help?

from django-address.

furious-luke avatar furious-luke commented on July 2, 2024

Yeah, I think, it is because I added Django-address after I had a few migrations in the project. When creating the new migration with addresses is when I ran into the issue of have a non-existing migration being a parent of another.

That's the process I used to generate the above output I attached, so not sure if that's the cause.

The only situation I can think of that might account for the issue you were seeing is if at some point you ran makemigrations and it generated the additional migration file in Django Address, and also added a dependency to that migration in one of your own migrations in your Django project, and then subsequent to that, that new migration file in Address was deleted. Then, the next time you ran makemigrations that migration in Address would be created again, but with a new filename, thus causing the missing migration.

From your initial post, it looks like the missing migration name was located in project_app, was your Django project called project by any chance?

from django-address.

daniel-butler avatar daniel-butler commented on July 2, 2024

No, it's not called project. I just changed the name to that.

Do you have a link you could share for the project that generated the migrations above? I'm missing the part where there are migrations in the project before address is added to the project.

I am also using django-tenants which could be attributing to the problem because migrations are split between the public tenant and all others.

from django-address.

furious-luke avatar furious-luke commented on July 2, 2024

Do you have a link you could share for the project that generated the migrations above?

Nope, sorry, I just threw it together based on the example site in Django Address.

As an alternative, could you create a minimal example that reproduces the issue you're seeing?

from django-address.

AntoineHessAcernis avatar AntoineHessAcernis commented on July 2, 2024

django-address version: 0.2.6

Hello guys ! I think I am facing the same problem here.

Do you think you will raise a PR soon ? I did not really understand the problem but I also have a depedency generated like this :

dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('contenttypes', '0002_remove_content_type_name'),
        ('address', '0004_alter_address_id_alter_country_id_alter_locality_id_and_more'),
    ]

I get this error when I migrate :

raise NodeNotFoundError(self.error_message, self.key, origin=self.origin) django.db.migrations.exceptions.NodeNotFoundError: Migration idt.0001_initial dependencies reference nonexistent parent node ('address', '0004_alter_address_id_alter_country_id_alter_locality_id_and_more')

I tried the solutions explained before but none of them worked.

from django-address.

furious-luke avatar furious-luke commented on July 2, 2024

Hi @AntoineHessAcernis and @daniel-butler! My apologies for the long delay, I've just published the latest version of Django Address containing the necessary fix to this issue. Please give it a go and let me know if anything goes awry.

from django-address.

daniel-butler avatar daniel-butler commented on July 2, 2024

Thank you for fixing, and all the work in this project!

from django-address.

AntoineHessAcernis avatar AntoineHessAcernis commented on July 2, 2024

Thank you @furious-luke, it works for me.

from django-address.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.