Migrations the right way

This commit is contained in:
PB
2025-11-08 17:54:22 +01:00
parent bceaa010ab
commit fc6970adc2
9 changed files with 88 additions and 266 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env sh
# run migrations
migrate.sh
migrate
exec "$@"

View File

@@ -1,26 +0,0 @@
#!/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