catalog-service/bin/migrate.sh

26 lines
398 B
Bash
Raw Permalink Normal View History

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