Skip to content

Commit 0480bdb

Browse files
Merge pull request letsencrypt#814 from letsencrypt/migrate-up
Add migrate-up script to easily do migrations.
2 parents b26eaae + 91e4e07 commit 0480bdb

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

test/create_db.sh

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
#!/bin/bash
2-
3-
function die() {
4-
if [ ! -z "$1" ]; then
5-
echo $1 > /dev/stderr
6-
fi
7-
exit 1
8-
}
9-
10-
SERVICES="ca
11-
sa
12-
policy"
13-
DBENVS="development
14-
test
15-
integration"
2+
cd $(dirname $0)/..
3+
source test/db-common.sh
164

175
for svc in $SERVICES; do
186
for dbenv in $DBENVS; do

test/db-common.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Common variables used by Goose-related scripts.
2+
set -o errexit
3+
set -o xtrace
4+
5+
function die() {
6+
if [ ! -z "$1" ]; then
7+
echo $1 > /dev/stderr
8+
fi
9+
exit 1
10+
}
11+
12+
SERVICES="ca
13+
sa
14+
policy"
15+
DBENVS="development
16+
test
17+
integration"

test/migrate-up.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
#
3+
# Run this script after pulling changes that have migrations, to migrate your
4+
# local DB.
5+
#
6+
cd $(dirname $0)/..
7+
8+
source test/db-common.sh
9+
10+
for svc in $SERVICES; do
11+
for dbenv in $DBENVS; do
12+
db="boulder_${svc}_${dbenv}"
13+
14+
goose -path=./$svc/_db/ -env=$dbenv up || die "unable to migrate ${db}"
15+
echo "migrated ${db} database"
16+
done
17+
done
18+
echo "migrated all databases"
19+

0 commit comments

Comments
 (0)