identity-service/bin/migrate.sh
2023-10-01 21:35:21 +02:00

27 lines
411 B
Bash

#!/usr/bin/env sh
# ensure migrate env is initialized
$(migrate version >/dev/null 2>&1)
version=$?
if [ $version != "0" ]
then
echo "Creating base table..."
$(migrate init >/dev/null 2>&1)
init=$?
fi
# check again
$(migrate version >/dev/null 2>&1)
version=$?
if [ $version != "0" ]
then
echo "Unable to run migrations."
exit 1
fi
# run migrations
migrate up
echo "Done."
exit $version