From e78cc9bd364725edb1e990bed4de5fec0d577df5 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 24 Apr 2018 15:05:55 -0400 Subject: [PATCH 1/2] Use --if-exists with import To resolve https://github.com/dokku/dokku-postgres/issues/142 --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index da9ddcf..7540549 100755 --- a/functions +++ b/functions @@ -114,7 +114,7 @@ service_import() { if [[ -t 0 ]]; then dokku_log_fail "No data provided on stdin." fi - docker exec -i "$SERVICE_NAME" env PGPASSWORD="$PASSWORD" pg_restore -h localhost -cO -d "$DATABASE_NAME" -U postgres -w + docker exec -i "$SERVICE_NAME" env PGPASSWORD="$PASSWORD" pg_restore -h localhost -cO --if-exists -d "$DATABASE_NAME" -U postgres -w } service_start() { From d143bb48b037b5b1bd22cbe951d65de93c061ed6 Mon Sep 17 00:00:00 2001 From: Dan Poirier Date: Mon, 30 Apr 2018 14:29:30 -0400 Subject: [PATCH 2/2] Update test to expect --if-exists on import --- tests/service_import.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/service_import.bats b/tests/service_import.bats index a9dfb1c..e6a83e5 100755 --- a/tests/service_import.bats +++ b/tests/service_import.bats @@ -32,6 +32,6 @@ teardown() { export ECHO_DOCKER_COMMAND="true" run dokku "$PLUGIN_COMMAND_PREFIX:import" l < "$PLUGIN_DATA_ROOT/fake.dump" password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" - assert_output "docker exec -i dokku.postgres.l env PGPASSWORD=$password pg_restore -h localhost -cO -d l -U postgres -w" + assert_output "docker exec -i dokku.postgres.l env PGPASSWORD=$password pg_restore -h localhost -cO --if-exists -d l -U postgres -w" }