Skip to content

Commit d509502

Browse files
committed
bug fix for dbs that use a non-default port
Former-commit-id: 4e30189
1 parent c7f0177 commit d509502

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pgdiff is written to be easy to expand and improve the accuracy of the diff.
1616

1717
(where options and <schemaType> are listed below)
1818

19-
I've found that there is an ideal order for running the different schema types. This order should minimize the problems you encounter. For example, you'll always want to add new tables before you add new columns. This is the order that has worked for me, however "your mileage may vary".
19+
I have found that there is an ideal order for running the different schema types. This order should minimize the problems you encounter. For example, you will always want to add new tables before you add new columns. This is the order that has worked for me, however "your mileage may vary".
2020

2121
Schema type ordering:
2222

@@ -35,11 +35,11 @@ Schema type ordering:
3535

3636

3737
### example
38-
I have found it helpful to take ```--schema-only``` dumps of the databases in question, load them into a local postgres, then do my sql generation and testing there before running the SQL against a more official database. Your local postgres instance will need the correct users/roles populated because db dumps don't copy that information.
38+
I have found it helpful to take ```--schema-only``` dumps of the databases in question, load them into a local postgres, then do my sql generation and testing there before running the SQL against a more official database. Your local postgres instance will need the correct users/roles populated because db dumps do not copy that information.
3939

4040
```
41-
pgdiff -U dbuser -H localhost -D refDB -O 'sslmode=disable' \
42-
-u dbuser -h localhost -d compDB -o 'sslmode=disable' \
41+
pgdiff -U dbuser -H localhost -D refDB -O "sslmode=disable" \
42+
-u dbuser -h localhost -d compDB -o "sslmode=disable" \
4343
TABLE
4444
```
4545

@@ -87,6 +87,7 @@ linux and osx binaries are packaged with an extra, optional bash script and pgru
8787
### version history
8888
1. 0.9.0 - Implemented ROLE, SEQUENCE, TABLE, COLUMN, INDEX, FOREIGN\_KEY, OWNER, GRANT\_RELATIONSHIP, GRANT\_ATTRIBUTE
8989
1. 0.9.1 - Added VIEW, FUNCTION, and TRIGGER (Thank you, Shawn Carroll AKA SparkeyG)
90+
1. 0.9.2 - Fixed bug when using the non-default port
9091

9192

9293
### todo

bin-linux/pgdiff.tgz.REMOVED.git-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a43bac9815b274229ca929f86bedc43fdd4454a1
1+
600e71ce85d88c6926576979759796def05d473a

bin-osx/pgdiff.tgz.REMOVED.git-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7ed89cdc6de9635e5c3d39e341153dbc949d56a3
1+
b884f831690e5540a876c40ca4c0f1b2e4e871a9

bin-win/pgdiff.exe.REMOVED.git-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d83feab2c337fca7826fb4a10152068b73c1e425
1+
3d77712778ba60aa35e07e3c96a367dc6f66df7c

pgdiff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Schema interface {
2525
}
2626

2727
const (
28-
version = "0.9.1"
28+
version = "0.9.2"
2929
)
3030

3131
var (

pgdiff.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,33 @@
55
#
66
# If you convert this to a windows batch file (or, even better, a Go program), please share it.
77
#
8-
# pgdiff -U postgres -W supersecret -D maindb -O sslmode=disable -u postgres -w supersecret -d stagingdb -o sslmode=disable COLUMN
8+
# Example:
9+
# pgdiff -U postgres -W supersecret -H dbhost1 -P 5432 -D maindb -O 'sslmode=disable' \
10+
# -u postgres -w supersecret -h dbhost2 -p 5432 -d stagingdb -o 'sslmode=disable' \
11+
# COLUMN
912
#
1013

1114
[[ -z $USER1 ]] && USER1=admin
1215
[[ -z $HOST1 ]] && HOST1=localhost
13-
[[ -z $NAME1 ]] && NAME1=prd-db
16+
[[ -z $PORT1 ]] && PORT1=5432
17+
[[ -z $NAME1 ]] && NAME1=main-db
1418
[[ -z $OPT1 ]] && OPT1='sslmode=disable'
1519

1620
[[ -z $USER2 ]] && USER2=admin
1721
[[ -z $HOST2 ]] && HOST2=localhost
18-
[[ -z $NAME2 ]] && NAME2=qa-db
22+
[[ -z $PORT2 ]] && PORT2=5432
23+
[[ -z $NAME2 ]] && NAME2=stg-db
1924
[[ -z $OPT2 ]] && OPT2='sslmode=disable'
2025

2126
echo "This is the reference database:"
22-
echo " ${USER1}@${HOST1}/$NAME1"
27+
echo " ${USER1}@${HOST1}:${PORT1}/$NAME1"
2328
read -sp "Enter DB password: " passw
2429
PASS1=$passw
2530
PASS2=$passw
2631

2732
echo
2833
echo "This database may be changed (if you choose):"
29-
echo " ${USER2}@${HOST2}/$NAME2"
34+
echo " ${USER2}@${HOST2}:${PORT2}/$NAME2"
3035
read -sp "Enter DB password (defaults to previous password): " passw
3136
[[ -n $passw ]] && PASS2=$passw
3237
echo
@@ -37,15 +42,15 @@ function rundiff() {
3742
local TYPE=$1
3843
local sqlFile="${i}-${TYPE}.sql"
3944
echo "Generating diff for $TYPE... "
40-
./pgdiff -U "$USER1" -W "$PASS1" -H "$HOST1" -D "$NAME1" -O "$OPT1" \
41-
-u "$USER2" -w "$PASS2" -h "$HOST2" -d "$NAME2" -o "$OPT2" \
42-
$TYPE > "$sqlFile"
45+
./pgdiff -U "$USER1" -W "$PASS1" -H "$HOST1" -P "$PORT1" -D "$NAME1" -O "$OPT1" \
46+
-u "$USER2" -w "$PASS2" -h "$HOST2" -p "$PORT2" -d "$NAME2" -o "$OPT2" \
47+
$TYPE > "$sqlFile"
4348
RC=$? && [[ $RC != 0 ]] && exit $RC
4449
echo -n "Press Enter to review the generated output: "; read x
4550
vi "$sqlFile"
4651
echo -n "Do you wish to run this against ${NAME2}? [yN]: "; read x
4752
if [[ $x =~ ^y ]]; then
48-
PGPASSWORD="$PASS2" ./pgrun -U $USER2 -h $HOST2 -d $NAME2 -O "$OPT2" -f "$sqlFile"
53+
PGPASSWORD="$PASS2" ./pgrun -U $USER2 -h $HOST2 -p $PORT2 -d $NAME2 -O "$OPT2" -f "$sqlFile"
4954
fi
5055
echo
5156
}

0 commit comments

Comments
 (0)