0

I just deploy my Django app to Heroku but I cant migrate my migrations to heroku. First I run : heroku run python manage.py migrate all the migrations list as OK but when I showmigrations, none of them is migrating (all blank [ ]).

Then I try heroku run bash and migrate from there, everything seems ok even showmigrations from bash showing all of the migrations is working. I even manage to create a superuser. But when I open my admin page and log in with superuser it shows 'account.account' table does not exist and when I check showmigrations again all of the migrations are gone. I have been repeating this migration over and over and still can't figure this out.

Does anyone know what I am doing wrong here?

Edit : I don't know if this is related but when I push my project to Heroku the first time, I'm using Postgre with this setting :

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': DB_NAME,
        'USER': DB_USER,
        'PASSWORD': DB_PASSWORD,
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

but when I try to run migrations it shows an error something like cant access localhost with 5432 port, it turns out that Heroku trying to access postgre in my localhost instead of using Heroku Postgres. The solution I found is to dump my db and reload it to Heroku. And since I don't know how to set that up. I just comment that postgre setting and replace it with default django setting :

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

create my dbsqlite file, running migrations again then once again push it to Heroku, hoping to find an easy way out but instead ended up in this problem

2 Answers 2

1

I'd recommend you to push a migrated project to heroku that is

python manage.py migrate

then push that migrated project to heroku

the reason your superuser doesn't get stored while creating superuser from heroku bash is because heroku has an ephemeral drive i.e heroku clears all the modified data from orignal push after equal interval of time.

Sign up to request clarification or add additional context in comments.

2 Comments

my app is already migrated before being pushed to Heroku
added the edit for a context, probably related with the problem
0

It turns out that I forgot to install django-heroku. More on this : https://devcenter.heroku.com/articles/django-app-configuration

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.