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.
This commit is contained in:
MickLesk
2026-09-17 10:11:23 +02:00
parent 8a43e3ddcd
commit ad271cf58d

View File

@@ -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