=== modified file 'zsh-functions/confz_postgresql_init' --- zsh-functions/confz_postgresql_init 2015-05-04 18:14:48 +0000 +++ zsh-functions/confz_postgresql_init 2015-05-04 18:02:16 +0000 @@ -134,66 +134,6 @@ return 1 } -confz_postgresql_schema_check() { - checkvars db owner schema_name - defvar user postgres - defvar psql psql - - local -a opts - - opts+=( -U $vars[user] ) - (($+vars[host])) && opts+=( --host=$vars[host] ) - (($+vars[port])) && opts+=( --port=$vars[port] ) - - do_command=( - $vars[psql] $opts $vars[db] -1 - -c "CREATE SCHEMA $vars[schema_name]; ALTER SCHEMA $vars[schema_name] OWNER $vars[owner]" - ) - - local out schema owner - out=$( confz_do $vars[psql] $opts -AP tuples_only=on -c '\dn' ) || die "psql failed" - while IFS='|' read schema owner; do - if [[ $schema == $vars[schema_name] ]]; then - [[ $owner == $vars[owner] ]] || \ - die "schema $schema has owner $owner, want $vars[owner]" - return 0 - fi - done <<<$out - - fail_reason="schema ${(qqq)vars[schema_name]} was not found in database ${(qqq)vars[db]}" - return 1 -} - -confz_postgresql_extension_check() { - checkvars db owner extension schema_name - defvar user postgres - defvar psql psql - - local -a opts - - opts+=( -U $vars[user] ) - (($+vars[host])) && opts+=( --host=$vars[host] ) - (($+vars[port])) && opts+=( --port=$vars[port] ) - - do_command=( - $vars[psql] $opts $vars[db] -1 - -c "CREATE EXTENSION $vars[extension] SCHEMA $vars[schema_name]" - ) - - local out extension version schema comment - out=$( confz_do $vars[psql] $opts -AP tuples_only=on -c '\dn' ) || die "psql failed" - while IFS='|' read extension version schema comment; do - if [[ $extension == $vars[extension] ]]; then - [[ $schema == $vars[schema_name] ]] || \ - die "extension $extension has schema $schema, want $vars[schema_name]" - return 0 - fi - done <<<$out - - fail_reason="extension ${(qqq)vars[extension]} was not found in database ${(qqq)vars[db]}" - return 1 -} - confz_postgresql_content_check() { checkvars db schema psql_input defvar user postgres