Description
Hi docker postgres experts,
I was wondering if it's worth to expose a way to execute a bash script every time the container spins up after executing the current logic in docker-entrypoint.sh
script. The example usage could be for data-migration. The desired execution would be along the line of:
- Execute current logic in
docker-entrypoint.sh
- Additional logic to perform data migration:
If database version is 1, then performmigration 1
,migration 2
,migration 3
Else if database version is 2, then performmigration 2
,migration 3
Else if database version is 3, then performmigration 3
Else do nothing
Step 2 can probably be executed by a bash script. Hence, in general, I think it's worth it to expose a way to specify a bash script every time the container spins up rather than just initialisation logic in folder docker-entrypoint-initdb.d
. Currently, the scripts in docker-entrypoint-initdb.d
only gets executed if the file $PGDATA/PG_VERSION
doesn't exists or has size 0. Meaning that if a database already exists, there is no way to perform any data-migration (that I know of).
Propose: we could specify another folder such as docker-data-migration.d
similar to docker-entrypoint-initdb.d
but any bash scripts in it will get run every time the container spins up.