order-service/bin/migrate.sh

26 lines
391 B
Bash
Raw Permalink Normal View History

2022-12-17 08:26:32 +01:00
#!/usr/bin/env sh
# ensure migrate env is initialized
$(migrate version >/dev/null 2>&1)
2022-12-17 08:26:32 +01:00
version=$?
if [ $version != "0" ]
then
echo "Creating base table..."
$(migrate init >/dev/null 2>&1)
2022-12-17 08:26:32 +01:00
init=$?
fi
# check again
$(migrate version >/dev/null 2>&1)
2022-12-17 08:26:32 +01:00
version=$?
if [ $version != "0" ]
then
echo "Unable to run migrations."
exit 1
fi
# run migrations
migrate up
2022-12-17 08:26:32 +01:00
exit 0