Added migrations
This commit is contained in:
@@ -3,13 +3,13 @@ set +e
|
||||
|
||||
waitForService()
|
||||
{
|
||||
./wait-for-it.sh $1 -t 2 1>/dev/null 2>&1
|
||||
wait-for-it.sh $1 -t 2 1>/dev/null 2>&1
|
||||
status=$?
|
||||
while [ $status != 0 ]
|
||||
do
|
||||
echo "[x] wating for $1..."
|
||||
sleep 1
|
||||
./wait-for-it.sh $1 -t 2 1>/dev/null 2>&1
|
||||
wait-for-it.sh $1 -t 2 1>/dev/null 2>&1
|
||||
status=$?
|
||||
done
|
||||
}
|
||||
@@ -19,6 +19,8 @@ waitForService "api-logger:24224"
|
||||
waitForService "api-registry:8500"
|
||||
# waitForService "api-eventbus:5672"
|
||||
|
||||
# run migrations
|
||||
migrate.sh
|
||||
|
||||
# set -euo pipefail
|
||||
|
||||
|
||||
26
bin/migrate.sh
Normal file
26
bin/migrate.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# ensure migrate env is initialized
|
||||
$(go_migrate version >/dev/null 2>&1)
|
||||
version=$?
|
||||
if [ $version != "0" ]
|
||||
then
|
||||
echo "Creating base table..."
|
||||
$(go_migrate init >/dev/null 2>&1)
|
||||
init=$?
|
||||
fi
|
||||
|
||||
# check again
|
||||
$(go_migrate version >/dev/null 2>&1)
|
||||
version=$?
|
||||
if [ $version != "0" ]
|
||||
then
|
||||
echo "Unable to run migrations."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# run migrations
|
||||
go_migrate up
|
||||
echo "Done."
|
||||
|
||||
exit $version
|
||||
Reference in New Issue
Block a user