mirror of
https://github.com/aljazceru/omakub.git
synced 2026-02-22 20:54:21 +01:00
Simplify migrations
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
cd $OMAKUB_PATH
|
||||
last_updated=$(git log -1 --format=%cd --date=unix)
|
||||
last_updated_at=$(git log -1 --format=%cd --date=unix)
|
||||
git pull
|
||||
currently_updated=$(git log -1 --format=%cd --date=unix)
|
||||
|
||||
if [ $last_updated -lt $currently_updated ]; then
|
||||
for file in $OMAKUB_PATH/migrations/*.sh; do
|
||||
# Extract the timestamp from the file name
|
||||
filename=$(basename "$file")
|
||||
timestamp="${filename%.sh}"
|
||||
for file in $OMAKUB_PATH/migrations/*.sh; do
|
||||
filename=$(basename "$file")
|
||||
migrate_at="${filename%.sh}"
|
||||
|
||||
# Run the migration script if the timestamp is before the current Git revision
|
||||
if [ $timestamp -lt $currently_updated ]; then
|
||||
source $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ $migrate_at -gt $last_updated_at ]; then
|
||||
echo "Running migration for $migrate_at"
|
||||
source $file
|
||||
fi
|
||||
done
|
||||
|
||||
cd -
|
||||
gum spin --spinner globe --title "Update has completed!" -- sleep 3
|
||||
|
||||
Reference in New Issue
Block a user