mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-09-17 10:14:00 +00:00
sparkyfitness: start the server through the entrypoint that migrates
The Better Auth CLI added in the previous commit is the wrong tool. It generates sso_provider.user_id as text and cannot reference this schema's uuid user.id: foreign key constraint "sso_provider_user_id_fkey" cannot be implemented [...] incompatible types: text and uuid The real cause is one line up in the unit. It ran tsx SparkyFitnessServer.js which imports the application module directly and never applies the schema migrations. Upstream starts through index.ts - nodemon.json has exec: tsx index.ts - and that file runs applyMigrations() and applyRlsPolicies() before importing anything, with a comment naming this exact failure: Better Auth validates the database schema eagerly, the moment betterAuth() is constructed at auth.ts module scope [...] When migrations ran later (from inside SparkyFitnessServer.ts) that check read the pre-migration schema on the first boot after an upgrade, so every /api/auth request failed until the container was restarted. Point both the install and the update at index.ts and drop the CLI call. index.ts exits non-zero when a migration fails, so systemd surfaces that instead of serving a broken login.
This commit is contained in:
@@ -52,19 +52,6 @@ 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
|
||||
@@ -99,7 +86,7 @@ function update_script() {
|
||||
Type=simple
|
||||
WorkingDirectory=/opt/sparkyfitness/SparkyFitnessServer
|
||||
EnvironmentFile=/etc/sparkyfitness/.env
|
||||
ExecStart=/opt/sparkyfitness/SparkyFitnessServer/node_modules/.bin/tsx SparkyFitnessServer.js
|
||||
ExecStart=/opt/sparkyfitness/SparkyFitnessServer/node_modules/.bin/tsx index.ts
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ Requires=postgresql.service
|
||||
Type=simple
|
||||
WorkingDirectory=/opt/sparkyfitness/SparkyFitnessServer
|
||||
EnvironmentFile=/etc/sparkyfitness/.env
|
||||
ExecStart=/opt/sparkyfitness/SparkyFitnessServer/node_modules/.bin/tsx SparkyFitnessServer.js
|
||||
ExecStart=/opt/sparkyfitness/SparkyFitnessServer/node_modules/.bin/tsx index.ts
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
|
||||
Reference in New Issue
Block a user