From 06e075d3a1d2533384735be47eb8be35af37bc4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Sat, 19 Sep 2015 00:09:24 +0200 Subject: [PATCH] Do not always allocate a tty on `connect` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To import SQL files `connect` has to be used instead of `import`. Doing so can’t work with the `-t` docker option, so now we check for a tty before using this option. Fixes #18 --- README.md | 8 ++++++++ commands | 3 ++- tests/service_connect.bats | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 16c9c79..bec4e52 100644 --- a/README.md +++ b/README.md @@ -117,3 +117,11 @@ $ dokku postgres:unlink db9.4 my_app # And last, destroy the old container $ dokku postgres:destroy db9.4 ``` + +## importing data + +The `import` command should be used with any non-plain-text files exported by `pg_dump`. To import a SQL file, use `connect` like this: + +```shell +$ dokku postgres:connect db < ./dump.sql +``` diff --git a/commands b/commands index 841b23a..49940d6 100755 --- a/commands +++ b/commands @@ -167,8 +167,9 @@ case "$1" in SERVICE="$2"; SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" DATABASE_NAME="$(get_database_name $SERVICE)" SERVICE_NAME="$(get_service_name "$SERVICE")" + has_tty && SERVICE_TTY_OPTS="-t" - docker exec -it "$SERVICE_NAME" psql -h localhost -U postgres "$DATABASE_NAME" + docker exec -i $SERVICE_TTY_OPTS "$SERVICE_NAME" psql -h localhost -U postgres "$DATABASE_NAME" ;; $PLUGIN_COMMAND_PREFIX:info) diff --git a/tests/service_connect.bats b/tests/service_connect.bats index af12662..6da30d1 100755 --- a/tests/service_connect.bats +++ b/tests/service_connect.bats @@ -24,6 +24,6 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:connect) success" { export ECHO_DOCKER_COMMAND="true" run dokku "$PLUGIN_COMMAND_PREFIX:connect" l - assert_output 'docker exec -it dokku.postgres.l psql -h localhost -U postgres l' + assert_output 'docker exec -i -t dokku.postgres.l psql -h localhost -U postgres l' }