-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathtest-sequence
executable file
·72 lines (60 loc) · 1.79 KB
/
test-sequence
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
#
# Useful for visually inspecting the output SQL to verify it is doing what it should
#
source ./start-fresh.sh >/dev/null
echo
echo ==========================================================
echo
#
# Compare the sequences between two schemas in the same database
#
./populate-db.sh db1 "
CREATE SCHEMA s1;
CREATE TABLE s1.table1 (id integer PRIMARY KEY); -- just for kicks
CREATE SEQUENCE s1.sequence_1
INCREMENT BY 2
MINVALUE 1024
MAXVALUE 99998
START WITH 2048
NO CYCLE
OWNED BY s1.table1.id;
CREATE SEQUENCE s1.sequence_2;
CREATE SCHEMA s2;
CREATE SEQUENCE s2.sequence_2;
CREATE SEQUENCE s2.sequence_3;
"
echo
echo "# Compare the sequences between two schemas in the same database"
echo "# Expect SQL (pseudocode):"
echo "# Add s2.sequence_1"
echo "# Drop s2.sequence_3"
echo
../pgdiff -U "u1" -W "asdf" -H "localhost" -D "db1" -S "s1" -O "sslmode=disable" \
-u "u1" -w "asdf" -h "localhost" -d "db1" -s "s2" -o "sslmode=disable" \
SEQUENCE | grep -v '^-- '
echo
echo ==========================================================
echo
#
# Compare the sequences in all schemas between two databases
#
./populate-db.sh db2 "
CREATE SCHEMA s1;
CREATE SEQUENCE s1.sequence_2;
CREATE SCHEMA s2;
CREATE SEQUENCE s2.sequence_2;
CREATE SEQUENCE s2.sequence_3;
CREATE SEQUENCE s2.sequence_4;
"
echo
echo "# Compare the sequences in all schemas between two databases"
echo "# Expect SQL (pseudocode):"
echo "# Add sequence s1.sequence_1"
echo "# Drop sequence s2.sequence_4"
echo
../pgdiff -U "u1" -W "asdf" -H "localhost" -D "db1" -S "*" -O "sslmode=disable" \
-u "u1" -w "asdf" -h "localhost" -d "db2" -s "*" -o "sslmode=disable" \
SEQUENCE | grep -v '^-- '
echo
echo