File tree Expand file tree Collapse file tree 3 files changed +33
-12
lines changed Expand file tree Collapse file tree 3 files changed +33
-12
lines changed Original file line number Diff line number Diff line change 1+
2+ psql -U u1 -h localhost -d db1 > /dev/null << EOS
3+ $1
4+ EOS
5+
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ sudo su - postgres -- << EOT
4+ psql <<'SQL'
5+ DROP DATABASE IF EXISTS db1;
6+ DROP DATABASE IF EXISTS db2;
7+ DROP USER IF EXISTS u1;
8+ CREATE USER u1 WITH SUPERUSER PASSWORD 'asdf';
9+ CREATE DATABASE db1 WITH OWNER = u1 TEMPLATE = template1;
10+ CREATE DATABASE db2 WITH OWNER = u1 TEMPLATE = template1;
11+ SQL
12+ EOT
13+
Original file line number Diff line number Diff line change 33# Useful for visually inspecting the output SQL to verify it is doing what it should
44#
55
6- sudo su - postgres -- << EOT
7- psql <<'SQL'
8- DROP DATABASE IF EXISTS db1;
9- DROP DATABASE IF EXISTS db2;
10- DROP USER IF EXISTS u1;
11- CREATE USER u1 WITH SUPERUSER PASSWORD 'asdf';
12- CREATE DATABASE db1 WITH OWNER = u1 TEMPLATE = template1;
13- CREATE DATABASE db2 WITH OWNER = u1 TEMPLATE = template1;
14- SQL
15- EOT
6+ source ./start-fresh.sh > /dev/null
7+
8+ # sudo su - postgres -- <<EOT
9+ # psql <<'SQL'
10+ # DROP DATABASE IF EXISTS db1;
11+ # DROP DATABASE IF EXISTS db2;
12+ # DROP USER IF EXISTS u1;
13+ # CREATE USER u1 WITH SUPERUSER PASSWORD 'asdf';
14+ # CREATE DATABASE db1 WITH OWNER = u1 TEMPLATE = template1;
15+ # CREATE DATABASE db2 WITH OWNER = u1 TEMPLATE = template1;
16+ # SQL
17+ # EOT
1618export PGPASSWORD=asdf
1719
1820echo
@@ -21,15 +23,16 @@ echo "# Compare the tables in two schemas in the same database"
2123#
2224# Compare the tables in two schemas in the same database
2325#
24- psql -U u1 -h localhost -d db1 << 'EOS '
26+ # psql -U u1 -h localhost -d db1 <<'EOS'
27+ ./add-schema.sh "
2528 CREATE SCHEMA s1;
2629 CREATE TABLE s1.table9 (id integer); -- to be added to s2
2730 CREATE TABLE s1.table10 (id integer);
2831
2932 CREATE SCHEMA s2;
3033 CREATE TABLE s2.table10 (id integer);
3134 CREATE TABLE s2.table11 (id integer); -- will be dropped from s2
32- EOS
35+ "
3336
3437
3538echo
You can’t perform that action at this time.
0 commit comments