Fix deployment/crash by improving schema migration logic - #9
Conversation
- Update tableInfos in server/index.js to include all relevant tables. - Add ensureColumn calls for characters, guild_ranks, audit_logs, and applications to handle missing columns in existing databases. - Specifically fix the "no such column: class" error reported in logs. - Fix a bug in POST /api/guilds where activityTimes was missing from the recruitment settings initialization. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR hardens the server’s SQLite startup migration to prevent deployments from crashing on older databases (e.g., missing columns like characters.class), and fixes guild creation by aligning recruitment settings inserts with the current schema.
Changes:
- Expanded schema introspection (
tableInfos) to include additional tables involved in migrations. - Added
ensureColumnmigrations for several newer columns incharacters,guild_ranks,audit_logs, andapplications. - Fixed
/api/guildscreation flow to includeactivityTimeswhen inserting default recruitment settings.
| ensureColumn('characters', 'class', 'TEXT NOT NULL') | ||
| ensureColumn('characters', 'role', 'TEXT NOT NULL') |
This PR addresses a deployment failure where the server would crash on startup with a
SqliteError: no such column: classwhen preparing statements.The root cause was that the automated schema migration logic in
server/index.jswas not tracking several tables (characters,guild_ranks,audit_logs,applications,email_verification_tokens,password_reset_tokens) and was not ensuring that their newer columns were present in existing SQLite databases.Changes:
tableInfos: Added all missing tables to the migration tracking object.ensureColumncalls for all essential columns in the affected tables, matching theirCREATE TABLEdefinitions. This ensures that the schema is always in sync with the code's expectations, even when deploying over an older database version./api/guildsPOST handler where theactivityTimesparameter was missing from the recruitment settings initialization call, which would have caused a runtime error withbetter-sqlite3.Verification:
npm test(all tests passed).npm run build(production build succeeded)./healthzendpoint response.PR created automatically by Jules for task 12920079633459169510 started by @RyanS4