I created extensions from /docker-entrypoint-initdb.d/* script like this:
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname db <<EOSQL
CREATE EXTENSION citext;
CREATE EXTENSION pgcrypto;
CREATE EXTENSION hstore;
CREATE EXTENSION unaccent;
CREATE EXTENSION pg_trgm;
EOSQL
**Sorry, we used outdated image. Actual command is:
gosu postgres postgres --single -jE <<EOSQL
CREATE EXTENSION citext;
CREATE EXTENSION pgcrypto;
CREATE EXTENSION hstore;
CREATE EXTENSION unaccent;
CREATE EXTENSION pg_trgm;
EOSQL
When I dump this database with pg_dumpall/pg_dump extensions does not exists in dump file and database restore fails.
pg_dump -U postgres -d userdb
pg_dumpall -U postgres
But if I connect to my database and do DROP/CREATE extension then my extensions are dumped and database successfully restored. My PostgreSQL server version is 11.12.
I found this answer and I do not understand p2. Does my CREATE EXTENSION counted as SQL script? If yes, why and how to make it non script?
I resolution I created next
999-recreate-extensions.shinitialization script. Here I created extensions viapsql:After this following
pg_dumpalldumpsCREATE EXTENSIONstatements.