Reputation: 43
Currently I'm running into issues with my models.py and Postgresql. The site is deployed on Heroku using Postgresql and the problem is models.py. Currently, I have models.py as a models.Charfield() and it works fine with sqlite, but when I deployed it to production, Postgresql still reports that it's a models.IntFied(). And because it's an integer field it won't allow for characters for some reason. Originally, I had it as a integerfield but decided to change to charfield, yet it still won't change to charfield. Solutions I've tried: resetting the database on heroku, deleting and recreating the database on heroku.
Any help is appreciated, Thanks
Upvotes: 1
Views: 54
Reputation: 21
I normally follow the steps in this order:
Ensure that your database changes have all been committed with git add and commit commands
Reset the heroku database, Run {heroku pg:reset DATABASE_URL}
Push your current changes to heroku with {git push heroku master}
Launch the heroku terminal {heroku run bash}
On the heroku terminal run {python manage.py migrate}
Upvotes: 1
Reputation: 3270
To sync your models to your database relational schema, you have to run the command:
python manage.py makemigrations
python manage.py migrate
Upvotes: 1