MasterRecord
Troubleshooting
Common errors and how to fix them.
If something isn’t working, it’s probably one of these.
“Cannot read or find Context file’AppContext.js’”#
The migration CLI resolves a context by file name. Your context must live in a file matching the name you pass:
bash
# file must be named AppContext.js
masterrecord enable-migrations AppContext“The ‘path’ argument must be of type string”#
You passed an inline config object to env() on a version older than 1.3.0. Upgrade, or use the environment-file form.
SQLite tries to create /db at the filesystem root#
Your connection starts with a leading slash. Use a relative path so it resolves under the project root:
json
{ "AppContext": { "type": "better-sqlite3", "connection": "db/" } }“near ‘)’: syntax error” when migrating#
Your entity defined fields as constructor object-literals instead of builder methods, so no columns were registered. Define fields as methods:
javascript
id(db) { db.integer().primary().auto(); } // ✅
title(db){ db.string(); } // ✅Configuration missing settings for context#
Your env JSON isn’t keyed by the context class name. Wrap settings under the context key:
json
{ "AppContext": { "type": "postgres", "host": "..." } }Still stuck?#
Tip
Set
LOG_SQL=true to print the exact SQL MasterRecord runs — invaluable for diagnosing query and migration issues. Open an issue with that output on the MasterRecord repo.