Django migration error in heroku postgres - django

I've just deployed my Django website on Heroku and while running the command to make migrations it shows a lot of migrations to apply but when I try to migrate it, it says no migrations to apply.
Here's a photo of it.

Related

What is the easiest way to reset migrations in Heroku CLI?

I recently deployed Django REST API project on Heroku and I wanted to remove migrations and migrate again.
I have tried:
heroku run python manage.py migrate --app cyberminds-backend zero
but it returns:
CommandError: No installed app with label 'zero'
What are the easiest steps or commands to achieve this?

Django on Heroku - ProgrammingError at / relation "..." does not exist

I'm getting this error. I know you usually get this error because the databases wasn't properly migrated.
When I run heroku local web, the website works fine when I go to localhost:5000.
However after I deploy the app to heroku with git push heroku master, the error comes up.
In other words, it works in my local environment. But it does not work after deploying to heroku.
I have Heroku-Postgres installed as an add-on in heroku.
What could be causing this?
excute migrations and makemigrations in bash heroku. open the terminal in the local project folder and give the following commands:
heroku run bash
~$ ./manage.py makemigrations
~$ ./manage.py migrate
~$ exit
The following steps did it for me
Make all the necessary migrations (python manage.py makemigrations) and migrate (python manage.py migrate) locally,
push to heroku master
and finally running heroku run python manage.py migrate
Solved the issue
I experienced the same error after making a change to a model and then deploying this change to heroku.
The only way I managed to fix this problem was to do the following:
Reset the database in heroku
Delete the migrations files from the migrations folder for the broken app locally (but keep the directory and the __init__.py file)
Run python manage.py makemigrations and python manage.py migrate. This will repopulate the migrations folder with clean migration files.
Push changes to master (ensure that you do not have migrations directories in .gitignore files.
Deploy changes to heroku
Run the heroku shell heroku run bash
Run python manage.py migrate
I was able to do this because my tables did not have much data in, but I would try to avoid resetting the database if I had more data in my tables.

django-background-tasks migrations on heroku

I am trying to migrate dajngo-background-tasks on my app hosted in heroku. Migrations worked normally locally but when I tried to run:
heroku run python manage.py migrate
It returned 'No migrations to apply'
I've added 'background_task', to INSTALLED_APPS
I ran
heroku run python manage.py makemigrations background_task
And it created the required migrations
I even tried running
heroku run python manage.py migrate background_task
causing "CommandError: App 'background_task' does not have migrations."
PS: One thing I noticed is that when running migrate locally I get this text
Apply all migrations: admin, background_task, auth, contenttypes, sessions, <my_app>
But when I run it on the server I get
Apply all migrations: admin, auth, contenttypes, sessions, <my_app>
Every form of help will be very much appreciated!
You must not run makemigrations via heroku run. You must run it locally, commit the resulting migrations and push them to heroku, then run them there.
This is due to missing migrations in the django-background-tasks package. This issue has been fixed in the latest version. If you install 1.1.9 the deployment to heroku should work.

problems updating DB to heroku with south migrations

I have a Django proyect running in heroku for some time now, the thing is that, tree days ago, I've tryed to update my schema model but, every time I write
heroku run python manage.py migrate quizzer
heroku keeps telling me that everything's up to date, but I've changed my models.py folder and run schema migration as always.
If you know why this is happening or how can I force a schema migration to my heroku app please tell me how.
Ps: I cannot delete the hole database as the data stored in heroku and the data stored in my local server database are not the same, and I don't want to loose the data of my users
Here is a workflow for running a schemamigration on quizzer after modifying your models.py
./manage.py schemamigration quizzer --auto # create migration
./manage.py migrate quizzer # apply migration locally
git add .
git commit -m "Changed quizzer models, added schemamigration"
git push heroku
heroku run python manage.py migrate quizzer # apply migration on heroku
It sounds like you might have forgotten to check your migration file (usually found in appname/migrations) into git, commit it and push it to heroku.
I had this problem too. I solved this by running heroku restart and running the migrate command again. Don't know why it works (suspect it has to do with initial), but at least it works.
Hope that helps!
South might be missing from requirements.txt. Try:
pip freeze > requirements.txt
...followed by another git add/commit/push.
Also, according to the South installation instructions, syncdb must be run first, "to make the South migration-tracking tables". So try:
heroku run python manage.py syncdb
...then try the migrate command again.

Deploying Django App stack that's been developed using South?

So, I've my application stack and I'm ready to deploy it to my webserver.
I'm deploying to a fresh, clean and blank database, so what command to I run? Do I run ./manage.py syncdb or do I use a South command to setup the database?
./manage.py syncdb
./manage.py migrate