basket-service/bin/migrate.sh

27 lines
411 B
Bash
Raw Normal View History

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