Python Version 2.7 Django Version 1.9.7
I have created a Django app on heroku. I can't get the heroku server to migrate
properly. In the past I have done all the makemigrations
locally and then pushed them to the server. It has worked in the past. Now I thought I would choose to do the migrations all on the server side, since I am not running this app locally at all.
I just created one new model inside the models.py
for app 'main':
from __future__ import unicode_literals
from django.db import models
class InstagramPhotos(models.Model):
imageId = models.IntegerField()
userId = models.IntegerField()
likes = models.IntegerField()
captionText = models.CharField(max_length=200)
image = models.ImageField()
After pushing changes to the server, I ran this, with following output:
heroku run python manage.py makemigrations main
Running python manage.py makemigrations main on ⬢ glacial-beach-50253... up, run.8354 Migrations for 'main':
0001_initial.py: - Create model InstagramPhotos
Seems ok right? So then I try to migrate
which as you know will actually create the tables in the DB:
heroku run python manage.py migrate
Running python manage.py migrate on ⬢ glacial-beach-50253... up, run.7556 Operations to perform: Apply all migrations: auth, contenttypes, admin, sessions Running migrations: No migrations to apply. Your models have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
No matter how many times I have tried to re-run the makemigrations
and then migrate
it still seems to not pick it up. Not sure why this is happening besides it is just not possible to operate on heroku server this way? Do I definitely need to do makemigrations
locally and push?
FYI I just have the default sqlite3 DB still defined in settings.py
.
I had a similar problem.
I just ssh
into heroku dyno with:
heroku run bash
( from your heroku application folder ofc )
Than run all the migration and makemigration commands with createsuperuser if needed. Works with sqlite and postgre for me.
python manage.py makemigrations,,, Python manage.py migrate
2.commit your code
3.push it to heroku master
heroku run python manage.py makemigrations,,,, heroku run python manage.py migrate
Your issue should be solved
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With