Skip to content

Troubleshooting

Timothy Ko edited this page May 20, 2018 · 1 revision

Troubleshooting

Here are some of the bugs I've commonly ran into

Database Versioning errors

If you are getting errors when you migrate, remove the migrations folder, go into the postgres CLI, connect to the database, and Drop the alembic_version table.

Note: For Docker, make sure to be inside the app container with docker-compose exec app bash beforehand.

$ rm -rf migrations/
$ exit

Now, for Docker, access bash for the postgres container to edit the database. Skip if you aren't using Docker

$ docker-compose exec postgres bash
# su - postgres

Then, for both Docker and Regular setup,

$ psql
# \connect testdb
# DROP TABLE alembic_version;
# \q
$ python manage.py db init
$ python manage.py db migrate
$ python manage.py db upgrade

Random errors

Sometimes you might run into weird errors. Since you most likely will run into these errors in the beginning(when your schema keeps changing) and, thus, will not have important data inside your database, you can just delete the database and start all over.

Note: For docker, you must be in the postgres container

$ psql
# DROP DATABASE testdb;
# create database testdb owner testusr encoding 'utf-8';
# GRANT ALL PRIVILEGES ON DATABASE testdb TO testusr;
# \q

Another way that might works is(for docker, you must be in the app container:

$ python manage.py recreate_db