From ad271cf58dd22ec0baeaf70a3071b22ff331ff19 Mon Sep 17 00:00:00 2001 From: MickLesk <47820557+MickLesk@users.noreply.github.com> Date: Thu, 17 Sep 2026 10:11:23 +0200 Subject: [PATCH] sparkyfitness: run the Better Auth migration during the update 1.7.1 ships a Better Auth version whose schema has columns 1.6.5 never created, and nothing in the update adds them. The backend starts, then refuses every sign-in: Database schema mismatch Missing columns session.impersonated_by two_factor.verified ... Run `npx auth migrate` to add the missing tables and columns. Run exactly that after the backend dependencies are in place, with the config Better Auth looks for, SparkyFitnessServer/auth.ts, and the database credentials from /etc/sparkyfitness/.env. Users who hit this were left running the server by hand to get the columns created. A failure warns instead of aborting: the rest of the update has already succeeded at that point, and the message names the remaining step. --- ct/sparkyfitness.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ct/sparkyfitness.sh b/ct/sparkyfitness.sh index 0daa9888b..b17d9e298 100644 --- a/ct/sparkyfitness.sh +++ b/ct/sparkyfitness.sh @@ -52,6 +52,19 @@ function update_script() { $STD pnpm install msg_ok "Updated Sparky Fitness Backend" + if [[ -f /opt/sparkyfitness/SparkyFitnessServer/auth.ts ]]; then + msg_info "Applying Better Auth Migrations" + cd /opt/sparkyfitness/SparkyFitnessServer + set -a + source /etc/sparkyfitness/.env + set +a + if $STD npx --yes @better-auth/cli migrate --config auth.ts -y; then + msg_ok "Applied Better Auth Migrations" + else + msg_warn "Better Auth migration failed - sign-in may report a schema mismatch until it is run by hand" + fi + fi + msg_info "Updating Sparky Fitness Frontend (Patience)" cd /opt/sparkyfitness $STD pnpm install