Skip to content

Commit

Permalink
Merge pull request #1151 from ashfall/upgrade-migrate
Browse files Browse the repository at this point in the history
Upgrade and pin mattes/migrate to the v3.0.0 tag
  • Loading branch information
endophage authored May 8, 2017
2 parents 2f3d6ed + abdd224 commit 9173e30
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
30 changes: 4 additions & 26 deletions migrations/migrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ case $SERVICE_NAME in
MIGRATIONS_PATH=${MIGRATIONS_PATH:-migrations/server/mysql}
DB_URL=${DB_URL:-mysql://server@tcp(mysql:3306)/notaryserver}
# have to poll for DB to come up
until migrate -path=$MIGRATIONS_PATH -url=$DB_URL version > /dev/null
until migrate -path=$MIGRATIONS_PATH -database="${DB_URL}" up
do
iter=$(( iter+1 ))
if [[ $iter -gt 30 ]]; then
Expand All @@ -20,24 +20,13 @@ case $SERVICE_NAME in
echo "waiting for $DB_URL to come up."
sleep 1
done
pre=$(migrate -path=$MIGRATIONS_PATH -url="${DB_URL}" version)
if migrate -path=$MIGRATIONS_PATH -url="${DB_URL}" up ; then
post=$(migrate -path=$MIGRATIONS_PATH -url="${DB_URL}" version)
if [ "$pre" != "$post" ]; then
echo "notaryserver database migrated to latest version"
else
echo "notaryserver database already at latest version"
fi
else
echo "notaryserver database migration failed"
exit 1
fi
echo "notaryserver database migrated to latest version"
;;
notary_signer)
MIGRATIONS_PATH=${MIGRATIONS_PATH:-migrations/signer/mysql}
DB_URL=${DB_URL:-mysql://signer@tcp(mysql:3306)/notarysigner}
# have to poll for DB to come up
until migrate -path=$MIGRATIONS_PATH -url=$DB_URL up version > /dev/null
until migrate -path=$MIGRATIONS_PATH -database="${DB_URL}" up
do
iter=$(( iter+1 ))
if [[ $iter -gt 30 ]]; then
Expand All @@ -47,17 +36,6 @@ case $SERVICE_NAME in
echo "waiting for $DB_URL to come up."
sleep 1
done
pre=$(migrate -path=$MIGRATIONS_PATH -url="${DB_URL}" version)
if migrate -path=$MIGRATIONS_PATH -url="${DB_URL}" up ; then
post=$(migrate -path=$MIGRATIONS_PATH -url="${DB_URL}" version)
if [ "$pre" != "$post" ]; then
echo "notarysigner database migrated to latest version"
else
echo "notarysigner database already at latest version"
fi
else
echo "notarysigner database migration failed"
exit 1
fi
echo "notarysigner database migrated to latest version"
;;
esac
6 changes: 2 additions & 4 deletions server.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ MAINTAINER David Lawrence "david.lawrence@docker.com"

RUN apk add --update git gcc libc-dev && rm -rf /var/cache/apk/*

# Pin to the specific v1 version
RUN git clone -b v1 https://github.com/mattes/migrate.git /go/src/github.com/mattes/migrate/ && \
go get github.com/mattes/migrate && \
go build -tags 'mysql' -o /usr/local/bin/migrate github.com/mattes/migrate
# Pin to the specific v3.0.0 version
RUN go get -tags 'mysql postgres file' github.com/mattes/migrate/cli && mv /go/bin/cli /go/bin/migrate

ENV NOTARYPKG github.com/docker/notary

Expand Down
6 changes: 2 additions & 4 deletions signer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ MAINTAINER David Lawrence "david.lawrence@docker.com"

RUN apk add --update git gcc libc-dev && rm -rf /var/cache/apk/*

# Pin to the specific v1 version
RUN git clone -b v1 https://github.com/mattes/migrate.git /go/src/github.com/mattes/migrate/ && \
go get github.com/mattes/migrate && \
go build -tags 'mysql' -o /usr/local/bin/migrate github.com/mattes/migrate
# Pin to the specific v3.0.0 version
RUN go get -tags 'mysql postgres file' github.com/mattes/migrate/cli && mv /go/bin/cli /go/bin/migrate

ENV NOTARYPKG github.com/docker/notary

Expand Down

0 comments on commit 9173e30

Please sign in to comment.