Last active
May 26, 2023 13:08
-
-
Save svandragt/73caba554f9e6a934cda926a2c2ece91 to your computer and use it in GitHub Desktop.
Basic migrate script that when run calls a number of bash functions to run only if they're not already migrated.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
do_upgrade() { | |
VERSION_FILE="migrations.version" | |
if [ ! -f $VERSION_FILE ]; then | |
touch $VERSION_FILE | |
fi | |
# List all the upgrades here | |
do_upgrade_profiler | |
} | |
do_upgrade_profiler() { | |
CHECK="profiler" | |
if ! grep -Fxq $CHECK "$VERSION_FILE"; then | |
echo "📦 Installing Profiler" | |
echo "<Installation routines>" && | |
echo $CHECK >>$VERSION_FILE | |
fi | |
} | |
do_upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this file contains a line per migration id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After running the version file contains the line "profiler" and the second time this script is run nothing happens.