gitlab: fix postgres calls

This commit is contained in:
Robin Gloster 2017-08-23 14:55:14 +02:00
parent 0156db2da5
commit 45605db3e0
No known key found for this signature in database
GPG Key ID: D5C458DF6DD97EDF

View File

@ -583,14 +583,14 @@ in {
if [ "${cfg.databaseHost}" = "127.0.0.1" ]; then if [ "${cfg.databaseHost}" = "127.0.0.1" ]; then
if ! test -e "${cfg.statePath}/db-created"; then if ! test -e "${cfg.statePath}/db-created"; then
psql postgres -c "CREATE ROLE ${cfg.databaseUsername} WITH LOGIN NOCREATEDB NOCREATEROLE NOCREATEUSER ENCRYPTED PASSWORD '${cfg.databasePassword}'" ${pkgs.sudo}/bin/sudo -u postgres psql postgres -c "CREATE ROLE ${cfg.databaseUsername} WITH LOGIN NOCREATEDB NOCREATEROLE ENCRYPTED PASSWORD '${cfg.databasePassword}'"
${config.services.postgresql.package}/bin/createdb --owner ${cfg.databaseUsername} ${cfg.databaseName} || true ${pkgs.sudo}/bin/sudo -u postgres ${config.services.postgresql.package}/bin/createdb --owner ${cfg.databaseUsername} ${cfg.databaseName}
touch "${cfg.statePath}/db-created" touch "${cfg.statePath}/db-created"
fi fi
fi fi
# enable required pg_trgm extension for gitlab # enable required pg_trgm extension for gitlab
psql gitlab -c "CREATE EXTENSION IF NOT EXISTS pg_trgm" ${pkgs.sudo}/bin/sudo -u postgres psql gitlab -c "CREATE EXTENSION IF NOT EXISTS pg_trgm"
# Always do the db migrations just to be sure the database is up-to-date # Always do the db migrations just to be sure the database is up-to-date
${gitlab-rake}/bin/gitlab-rake db:migrate RAILS_ENV=production ${gitlab-rake}/bin/gitlab-rake db:migrate RAILS_ENV=production