[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.

๐Ÿ‘คDishant Chavda

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.

๐Ÿ‘คanaco ndeda

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.

๐Ÿ‘คKennedy Lucas

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