Search code examples
pythondjangodatabaseheroku

Add column Heroku database


Goodnight.

I have a project done in Python and Django and today I added one more Model Table and added a column manually and it worked in the development environment.

But when deploying to Heroku , Heroku cannot find this manually created column and returns this error "column does not exist" .

How do I manually add a column to the Heroku database?


Solution

  • Heroku cannot find this manually created column

    Of course it can't. You created it on another database.

    Manually modifying your database schema is a bad idea, especially if you're using a framework like Django that has database migrations built in. Modify your models and generate a migration with python manage.py makemigrations, or create a migration manually. Test the migration and commit it when you're happy with it.

    Then push do Heroku and run your migrations there by running heroku run python manage.py migrate. Some users like to set this as a release task so it runs automatically.