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