Closed daniel-butler closed 2 years ago
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
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.
It happened again when I recreated the migrations. It is possible I am doing something wrong, though.
I think that is it. I'll try it tomorrow!
That was the issue! This was the fix
INSTALLED_APPS = [
...
"project.apps.ModifiedAddressConfig",
...
]
"""
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"
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:
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?
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?
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?
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.
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?
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!
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.
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.
Thank you for fixing, and all the work in this project!
Thank you @furious-luke, it works for me.
django-address version: 0.2.6
When creating a new project I am getting the error below when running
python manage.py migrate
. I've removed the pyc files and deleted all migration files and recreated them usingmakemigrations
a few times.I'm thinking that the django-address release doesn't have the migration? But then how does the migration in my project app know the name and value of it.
settings.py
Migration file
When running migrations it is updating the id field.
Error