[Fixed]-Django makemigrations and migrate on heroku server don't create tables

28👍

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.

1👍

  1. Run these commands locally:
python manage.py makemigrations 
python manage.py migrate
  1. Commit your code

  2. Push it to Heroku master

  3. Run

heroku run python manage.py makemigrations 
heroku run python manage.py migrate

Your issue should be resolved now.

1👍

I struggled recently with a similar error and ended discovering that i mistakenly have been git ignoring init.py files. Without these files in the migrations folder, the migrate command cannot find the migration files and execute them.

1👍

Run makemigrations and migrate, then pushed to remote repo.

👤hmfzer

0👍

I ran into the same error two times while deploying to Heroku. While listing the files under the app directory, I found out db.sqlite3 file was missing which is necessary for django to create the sql tables. While it automatically creates the file in local, it wasn’t getting created on the heroku while running migrate command.

There are two options from here:

  1. create db.sqlite3 file on heroku under your app directory
  2. run "python manage.py migrate" locally to create the db.sqlite3 and push it to the
    heroku repo
👤ac_baz

Leave a comment