Skip to content

Commit 7423318

Browse files
authored
Merge pull request #19 from MagikIO/claude/fix-cauldron-update-parallel-01VBwD1Z5S39ZJnswcwafhgf
fix: make dependencies table migration idempotent and add to cauldron…
2 parents 8b5bd72 + 4ab6742 commit 7423318

3 files changed

Lines changed: 50 additions & 7 deletions

File tree

data/update.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Add date column to dependencies table if it doesn't exist (for parallel installation tracking)
2-
ALTER TABLE dependencies ADD COLUMN date TEXT;
2+
-- Note: This migration is handled by cauldron_update script to ensure idempotency
33

44
INSERT INTO "familiars" ("id", "name", "display_name", "familiar_type", "unlocked", "cow_src_ext", "nickname") VALUES ('8', 'vault-boy', NULL, 'Meme', '1', '1', NULL);
55
INSERT INTO "familiars" ("id", "name", "display_name", "familiar_type", "unlocked", "cow_src_ext", "nickname") VALUES ('9', 'wheatley', NULL, 'Meme', '1', '1', NULL);

functions/cauldron_repair.fish

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,21 @@ function cauldron_repair --description "Repair broken Cauldron installation"
7878
end
7979
end
8080

81-
# Check 4: Verify functions are installed
81+
# Check 4: Verify dependencies table has date column
82+
if test -f "$CAULDRON_DATABASE"
83+
echo "→ Checking dependencies table schema..."
84+
set -l has_date_column (sqlite3 "$CAULDRON_DATABASE" "PRAGMA table_info(dependencies);" 2>/dev/null | grep -c "date")
85+
86+
if test $has_date_column -eq 0
87+
set issues_found (math $issues_found + 1)
88+
set -a issues "Dependencies table missing 'date' column (required for parallel installs)"
89+
echo " ✗ Dependencies table schema outdated"
90+
else
91+
echo " ✓ Dependencies table schema OK"
92+
end
93+
end
94+
95+
# Check 5: Verify functions are installed
8296
echo "→ Checking Fish functions..."
8397
set -l functions_dir "$HOME/.config/cauldron/functions"
8498

@@ -114,7 +128,7 @@ function cauldron_repair --description "Repair broken Cauldron installation"
114128
end
115129
end
116130

117-
# Check 5: Verify data files
131+
# Check 6: Verify data files
118132
echo "→ Checking data files..."
119133
set -l required_files palettes.json spinners.json
120134

@@ -135,7 +149,7 @@ function cauldron_repair --description "Repair broken Cauldron installation"
135149
echo " ✓ Data files OK"
136150
end
137151

138-
# Check 6: Verify Fish config
152+
# Check 7: Verify Fish config
139153
echo "→ Checking Fish configuration..."
140154
set -l fish_config "$HOME/.config/fish/config.fish"
141155

@@ -216,7 +230,29 @@ function cauldron_repair --description "Repair broken Cauldron installation"
216230
end
217231
end
218232

219-
# Fix 2: Reinstall functions
233+
# Fix 2: Update dependencies table schema
234+
if string match -q "*Dependencies table*" -- $issues
235+
echo " → Updating dependencies table schema..."
236+
237+
# Check if the date column exists before trying to add it
238+
set -l has_date_column (sqlite3 "$CAULDRON_DATABASE" "PRAGMA table_info(dependencies);" 2>/dev/null | grep -c "date")
239+
240+
if test $has_date_column -eq 0
241+
sqlite3 "$CAULDRON_DATABASE" "ALTER TABLE dependencies ADD COLUMN date TEXT;" 2>/dev/null
242+
243+
if test $status -eq 0
244+
echo " ✓ Added date column to dependencies table"
245+
set issues_fixed (math $issues_fixed + 1)
246+
else
247+
echo " ✗ Failed to add date column"
248+
end
249+
else
250+
echo " ✓ Date column already exists"
251+
set issues_fixed (math $issues_fixed + 1)
252+
end
253+
end
254+
255+
# Fix 3: Reinstall functions
220256
if string match -q "*function*" -- $issues
221257
echo " → Reinstalling functions..."
222258

@@ -244,7 +280,7 @@ function cauldron_repair --description "Repair broken Cauldron installation"
244280
set issues_fixed (math $issues_fixed + 1)
245281
end
246282

247-
# Fix 3: Restore data files
283+
# Fix 4: Restore data files
248284
if string match -q "*data file*" -- $issues
249285
echo " → Restoring data files..."
250286

@@ -262,7 +298,7 @@ function cauldron_repair --description "Repair broken Cauldron installation"
262298
set issues_fixed (math $issues_fixed + 1)
263299
end
264300

265-
# Fix 4: Fix Fish config
301+
# Fix 5: Fix Fish config
266302
if string match -q "*Fish config*" -- $issues
267303
echo " → Updating Fish configuration..."
268304

update/cauldron_update.fish

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ function cauldron_update -d 'Update Cauldron to the latest version'
175175
sqlite3 $CAULDRON_DATABASE < $CAULDRON_PATH/data/update.sql 2> /dev/null
176176
end
177177

178+
# Add date column to dependencies table if it doesn't exist (for parallel installation tracking)
179+
# Check if the column exists before trying to add it
180+
set has_date_column (sqlite3 $CAULDRON_DATABASE "PRAGMA table_info(dependencies);" | grep -c "date")
181+
if test $has_date_column -eq 0
182+
sqlite3 $CAULDRON_DATABASE "ALTER TABLE dependencies ADD COLUMN date TEXT;" 2> /dev/null
183+
end
184+
178185
# List of folders with functions
179186
set CAULDRON_LOCAL_DIRS "alias" "cli" "config" "effects" "functions" "familiar" "internal" "setup" "text" "UI" "update"
180187

0 commit comments

Comments
 (0)