I made a bunch of changes to my models locally and ran makemigrations and migrate commands localy. Locally everything runs smooth.
After that I did ‘fly deploy’ which succeeded. Then I ran the command fly ssh console -C "python manage.py makemigrations my_app"
and to my surprise it says “No changes were detected”. I also get a bunch of errors when I ran migrate after that just to see.
Can anyone help with this issue? Why is it not picking up the modeling changes in the fly deployment? Thanks!
If so, you migration are applied automatically during deployment (fly deploy).
makemigration command creates the new migration files. You should create the new migration files locally and deploy them to production. In production you should just apply (migrate) them - manually, with fly ssh console -C "python manage.py migrate my_app" or automatically, with the release_command on fly.toml (as mentioned before).
You can also check if the migrations were applied by doing:
Hi @katia thanks for the reply. I checked the showmigrations output and see that the last 2 migrations haven’t been applied. I actually changed the base auth User model and implemented my custom one using AbstractUser. Perhaps there’s an issue with the migration on the fly node due to some conflicts related to this. The app is still in dev phase. Is there anything I can do to force apply the latest model changes?
Also my fly.toml doesn’t have release_command = “python manage.py migrate”
@katia Thanks for the reply. Yes and it didn’t work. Like I mentioned, I introduced a custom User model. I did all of the migration on local and tested the app on my local machine. Then I ran the following commands
fly ssh console -C “python manage.py makemigrations my_app”
- here the output was that “no changes were detected”
When I ran 3, it complained that "...'my_app' doesn't provide model 'custom_user'..." at a bunch of places…
I didn’t face this issue when I migrated locally. What can I do to resolve this on the fly deployment?
That’s correct. When you deploy your app, all the changes are should be there (including the new migration files).
Can you check your local migration and production migration and post them here?
You can run python manage.py showmigrations my_app in your local and then fly ssh console -C "python manage.py showmigrations my_app" to compare them.
@katia I have the correct AUTH_USER_MODEL in settings.py. I also didn’t change anything in the non-applied migration files (or any migration files for that matter).
If the django project was misconfigured, then I should have seen errors when I ran it locally, right?
I tested the app locally end to end and its working as expected.
Thanks @katia. I’ve added that to the toml file. I had to actually nuke the entire project on fly and recreate it unfortunately. Since I’m still in dev mode I didn’t have to worry about data migrations, etc. Now it works fine. Hopefully I don’t run into this in the futue.