Added migrations

This commit is contained in:
PB
2022-12-17 06:31:35 +01:00
parent 78418b230d
commit 0a684d45f9
9 changed files with 280 additions and 37 deletions

26
bin/migrate.sh Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env sh
# ensure migrate env is initialized
$(go_migrate version >/dev/null 2>&1)
version=$?
if [ $version != "0" ]
then
echo "Creating base table..."
$(go_migrate init >/dev/null 2>&1)
init=$?
fi
# check again
$(go_migrate version >/dev/null 2>&1)
version=$?
if [ $version != "0" ]
then
echo "Unable to run migrations."
exit 1
fi
# run migrations
go_migrate up
echo "Done."
exit $version