diff --git a/.gitattributes b/.gitattributes index dfe077042..50b830be9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,5 @@ # Auto detect text files and perform LF normalization * text=auto + +# Force LF for shell scripts (prevents CRLF breakage in Docker containers) +*.sh text eol=lf diff --git a/docker/init/setup.sh b/docker/init/setup.sh index 46e16274a..78639a18e 100644 --- a/docker/init/setup.sh +++ b/docker/init/setup.sh @@ -1,22 +1,19 @@ #!/bin/bash set -e -echo "INIT!" -pg_restore --username="$POSTGRES_USER" --dbname="$POSTGRES_DB" --verbose /schemas/init.sql - +echo "INIT: Restoring database schema..." +pg_restore --username="$POSTGRES_USER" --dbname="$POSTGRES_DB" --no-owner --no-acl --verbose /schemas/init.sql || { + echo "WARN: pg_restore exited with errors (this is expected if the database already has objects)" +} echo "Updating!" - -for file in /schemas/update-schema/* -do - psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -1 -f $file +for file in /schemas/update-schema/*; do + echo " Applying $file" + psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -1 -f "$file" done - - echo "Patching!" - -for file in /schemas/patch-schema/* -do - psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -1 -f $file +for file in /schemas/patch-schema/*; do + echo " Applying $file" + psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -1 -f "$file" done \ No newline at end of file