Skip to content

Commit 4c36ac2

Browse files
authored
Merge pull request #22 from input-output-hk/erikd/script-update
scripts/postgresql-setup.sh: Update two commands
2 parents bda978e + 10de993 commit 4c36ac2

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

scripts/postgresql-setup.sh

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,16 @@ function list_views {
9595
}
9696

9797
function create_migration {
98-
cabal build cardano-explorer-db:cardano-explorer-db-manage
99-
exe=$(find dist-newstyle -type f -name cardano-explorer-db-manage)
100-
"${exe}" create-migration --mdir schema/
98+
echo "To create a migration:"
99+
echo "cabal run create-migration --mdir schema/"
100+
exit 0
101101
}
102102

103103
function run_migrations {
104-
cabal build cardano-explorer-db:cardano-explorer-db-manage
105-
exe=$(find dist-newstyle -type f -name cardano-explorer-db-manage)
106-
"${exe}" run-migrations --mdir schema/ --ldir .
104+
echo "To run migrations:"
105+
echo "cabal run cardano-db-tool run-migrations --mdir schema/ --ldir ."
106+
echo "You probably do not need to do this."
107+
exit 0
107108
}
108109

109110
function dump_schema {
@@ -119,7 +120,7 @@ function usage_exit {
119120
echo " $progname --list-views - List the currently definied views."
120121
echo " $progname --recreatedb - Drop and recreate database."
121122
echo " $progname --create-user - Create database user (from config/pgass file)."
122-
echo " $progname --create-migration - Create a migration (if one is needed)."
123+
echo " $progname --create-migration - Create a migration (if one is needed)."
123124
echo " $progname --run-migrations - Run all migrations applying as needed."
124125
echo " $progname --dump-schema - Dump the schema of the database."
125126
echo
@@ -166,6 +167,9 @@ case "${1:-""}" in
166167
check_connect_as_user
167168
drop_db
168169
create_db
170+
echo "The database ${databasename} has been dropped and recreated."
171+
echo "The tables will be recreated when the application is run."
172+
exit 0
169173
;;
170174
--create-user)
171175
check_pgpass_file
@@ -174,20 +178,9 @@ case "${1:-""}" in
174178
create_user
175179
;;
176180
--create-migration)
177-
check_pgpass_file
178-
check_for_psql
179-
check_psql_superuser
180-
check_db_exists
181-
check_connect_as_user
182181
create_migration
183182
;;
184183
--run-migrations)
185-
check_pgpass_file
186-
check_for_psql
187-
check_psql_superuser
188-
check_db_exists
189-
check_connect_as_user
190-
# Migrations are designed to be idempotent, so can be run repeatedly.
191184
run_migrations
192185
;;
193186
--dump-schema)

0 commit comments

Comments
 (0)