From 0a3ce5c393d442febeed3b33ae40128752abe37b Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Sun, 31 Aug 2025 08:03:25 +0100 Subject: [PATCH] Allow failed migrations to be skipped (#1124) * Allow failed migrations to be skipped Failed migrations can be now be skipped by a prompt. This means that if a migration is "stuck" then a user can opt to store it in a separate skipped directory. Skipped migrations will be considered for the purposes of running the pending migrations, however in future, we can allow the user to run their skipped migrations with a flag. To allow the script to continue and prompt for failed migrations, the `set -e` has been removed. A manual check on the exit code is used instead. * Cleanup implementation a bit --------- Co-authored-by: David Heinemeier Hansson --- bin/omarchy-migrate | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/omarchy-migrate b/bin/omarchy-migrate index 00e6556..0f7ba64 100755 --- a/bin/omarchy-migrate +++ b/bin/omarchy-migrate @@ -1,18 +1,27 @@ #!/bin/bash -set -e - # Where we store an empty file for each migration that has already been performed. STATE_DIR="$HOME/.local/state/omarchy/migrations" mkdir -p "$STATE_DIR" +# Skipped migrations are tracked separately +mkdir -p "$STATE_DIR/skipped" + # Run any pending migrations for file in ~/.local/share/omarchy/migrations/*.sh; do filename=$(basename "$file") - if [[ ! -f "$STATE_DIR/$filename" ]]; then + if [[ ! -f "$STATE_DIR/$filename" && ! -f "$STATE_DIR/skipped/$filename" ]]; then echo -e "\e[32m\nRunning migration (${filename%.sh})\e[0m" - source $file - touch "$STATE_DIR/$filename" + + if bash -e $file; then + touch "$STATE_DIR/$filename" + else + if gum confirm "Migration ${filename%.sh} failed. Skip and continue?"; then + touch "$STATE_DIR/skipped/$filename" + else + exit 1 + fi + fi fi done