Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 07fe4f8

Browse files
committed
Copy Postgres data across to a fresh DB when migrating on Heroku
This works around #183 by avoiding reuse of the old Ruby app. Note that we don't copy over the Redis data; this is only used to sync websockets and considered ephemeral.
1 parent 1d2f534 commit 07fe4f8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

deployment/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ So you're ready to set Postfacto up, choose a name for your app. We'll refer to
9191

9292
### Migrating a deployment
9393

94+
> ⚠️ **Warning**: the Heroku migration will attempt to migrate your data to a new database instance and delete the old one. Take a look at what the script is doing and make sure you understand the implications before running it.
95+
9496
1. If you'd previously deployed a version of Postfacto prior to 4.0, run the migration script from the `heroku` directory:
9597
```bash
9698
./migrate.sh <web-app-name> <api-app-name>

deployment/migrate-heroku.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ SESSION_TIME=${SESSION_TIME:-'""'}
4545
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4646
"$SCRIPT_DIR/mixpanel.sh" "Heroku $(basename "${BASH_SOURCE[0]}")" "$@"
4747

48-
ENABLE_ANALYTICS=false "$SCRIPT_DIR/upgrade.sh" ${API_HOST}
48+
heroku addons:create heroku-postgresql:hobby-dev -a ${WEB_HOST}
49+
heroku pg:copy DATABASE ${WEB_HOST}::DATABASE -a ${API_HOST} --confirm ${API_HOST}
50+
heroku addons:create heroku-redis:hobby-dev -a ${WEB_HOST}
51+
heroku config:set WEBSOCKET_PORT=4443 SESSION_TIME=${SESSION_TIME} -a ${WEB_HOST}
4952

50-
heroku apps:delete -a ${WEB_HOST} -c ${WEB_HOST}
51-
heroku apps:rename -a ${API_HOST} ${WEB_HOST}
53+
ENABLE_ANALYTICS=false "$SCRIPT_DIR/upgrade.sh" ${WEB_HOST}
54+
55+
heroku apps:delete -a ${API_HOST} -c ${API_HOST}

0 commit comments

Comments
 (0)