Home > front end >  Add column Heroku database
Add column Heroku database

Time:10-20

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?

CodePudding user response:

I'm not sure you should be managing your tables manually but if you must do it manually and you're using Heroku Postgres, you can use the Heroku CLI to open a psql session:

heroku pg:psql

Note you will need PostgreSQL installed locally. See docs for more details.

CodePudding user response:

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.

  • Related