0

I know that when launching a web app that uses a Docker Postgres DB, I can include an initialization script (init.sql) that sets up the database and adds initial tables and populates these with data:

volumes:
    - ./init.sql:/docker-entrypoint-initdb.d/init.sql

In the docs it says that this init process will only run on the first spinnup of the DB. What if in future deployments I want to add another table or extend an existing table with a column and potentially even add further data? Is this possible with some modification script that will run during deployment automatically (CI/CD) or do I have to make the changes manually in the DB before deploying?

imarevic
  • 45
  • 5
  • you need to generate persistent data volumes, and all changes to the database structure you need to save in your app through migration tools. here more examples https://stackoverflow.com/questions/39175194/docker-compose-persistent-data-mysql – Salines Feb 01 '22 at 08:19

0 Answers0