Ways to migrate DB

The postgres image automatically creates the default database if it does not exist. However, currently, nothing ensures that the migrations have been run. In development, we just did this manually by:

docker-compose exec web bin/rails db:migrate

Using .sh file

We need to ensure that our app has a fully migrated database when it launches. One way you might think of achieving this is with the entry-point concept we used to solve the server PID issue. We already have a docker-entrypoint.sh file that is run just prior to launching our app. This might lead you to try migrating the database as follows:

Get hands-on with 1200+ tech skills courses.