testdrivenio / testdriven-app

34 stars 18 forks source link

users_dev does not exist #29

Open kbhagi opened 4 years ago

kbhagi commented 4 years ago

Hi Michael, There are 2 docker containers created called nlp-ml-app_users_1 and nlp-ml-app_users-db_1 which are up and running.

They are still running even after I face the below error Check the image below .

image I have followed this tutorial successfully upto this command docker-compose exec users python manage.py recreate_db at the page https://testdriven.io/courses/tdd-flask/flask-blueprints/

When i run the highlighted command I am facing this error users_dev does not exist

Even after tried all these commands , i get the same error $ docker-compose stop $ docker-compose rm docker-compose down -v

kbhagi commented 4 years ago

Solution to database users_dev does not exist

For the problem where databases were not getting created , i have found a solution which worked. After diving deep into the logs of this database container nlp-ml-app_users-db_1

  , I came to know that create.sql  was not getting copied into this directory  /docker-entrypoint-initdb.d

Every time I made a change to any files at the project could be python or Dockerfile or shell script I was missing to build the Docker Image . Due to this /docker-entrypoint-initdb.d/ was being ignored by the Docker

The solution is outlined as below.

Missed Command : docker-compose build

Step 1. docker-compose stop Step 2. docker-compose rm Step 3. docker-compose down -v Step 4. docker-compose build Step 5. docker-compose up -d

Adding this command in bold to the set of commands that need to be run solved the problem .  When I ran   docker-compose exec users python manage.py recreate_db ,  no more I faced an error.