Skip to content

Commit

Permalink
Fix upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolidori committed Aug 14, 2024
1 parent b295afb commit 10e33a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ COMPOSE_FILES = -f docker-compose.yaml -f .docker-compose-db.yaml -f .docker-com

DATAPUSHER_TYPE ?= datapusher-plus
CKAN_DB_NAME ?= ckan
CKAN_DB_USER ?= ckan
DB_USERNAME ?= postgres
CKAN_DB_USERNAME ?= ckan
DB_USERNAME ?= postgres
DATASTORE_DB_NAME ?= datastore
DATASTORE_DB_USERNAME ?= postgres

Expand Down Expand Up @@ -72,4 +71,4 @@ backup-db:
docker-compose $(COMPOSE_FILES) exec -T datastore-db pg_dump -U postgres --format=custom -d datastore > datastore.dump

upgrade-db:
./db/migration/upgrade_databases.sh "$(COMPOSE_FILES)" "$(CKAN_DB_NAME)" "$(CKAN_DB_USERNAME)" "$(DB_USERNAME)" "$(CKAN_DB_USERNAME)" "$(DATASTORE_DB_NAME)" "$(DATASTORE_DB_USERNAME)"
./db/migration/upgrade_databases.sh "$(COMPOSE_FILES)" "$(CKAN_DB_NAME)" "$(CKAN_DB_USERNAME)" "$(DB_USERNAME)" "$(DATASTORE_DB_NAME)" "$(DATASTORE_DB_USERNAME)"
18 changes: 9 additions & 9 deletions db/migration/upgrade_databases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

COMPOSE_FILES=$1
CKAN_DB_NAME=$2
DB_USERNAME=$3
CKAN_DB_USERNAME=$4
CKAN_DB_USERNAME=$3
DB_USERNAME=$4
DATASTORE_DB_NAME=$5
DATSTORE_DB_USERNAME=$6

Expand Down Expand Up @@ -53,13 +53,6 @@ reset_database() {
reset_database ${CKAN_DB_NAME} ${DB_SERVICE} ${CKAN_DB_USERNAME}
reset_database ${DATASTORE_DB_NAME} ${DATASTORE_SERVICE} ${DATSTORE_DB_USERNAME}

echo ""
echo "### Create ROLE and DATABASE for datapusher_jobs in Datastore database..."
echo ""

docker-compose ${COMPOSE_FILES} exec -T ${DATASTORE_SERVICE} psql -U ${DB_USERNAME} -c "CREATE ROLE datapusher_jobs WITH LOGIN PASSWORD '123456';"
docker-compose ${COMPOSE_FILES} exec -T ${DATASTORE_SERVICE} psql -U ${DB_USERNAME} -c "CREATE DATABASE datapusher_jobs OWNER datapusher_jobs ENCODING 'utf8';"

echo ""
echo "### ROLE and DATABASE for datapusher_jobs created in Datastore database."

Expand All @@ -81,6 +74,13 @@ docker-compose ${COMPOSE_FILES} exec -T ${DATASTORE_SERVICE} pg_restore -U postg
echo ""
echo "### Restoring Datastore DB from backup completed."

echo ""
echo "### Create ROLE and DATABASE for datapusher_jobs in Datastore database..."
echo ""

docker-compose ${COMPOSE_FILES} exec -T ${DATASTORE_SERVICE} psql -U ${DB_USERNAME} -c "CREATE ROLE datapusher_jobs WITH LOGIN PASSWORD '123456';"
docker-compose ${COMPOSE_FILES} exec -T ${DATASTORE_SERVICE} psql -U ${DB_USERNAME} -c "CREATE DATABASE datapusher_jobs OWNER datapusher_jobs ENCODING 'utf8';"

echo ""
echo "### Restoring data files to CKAN..."
echo ""
Expand Down

0 comments on commit 10e33a6

Please sign in to comment.