Foreign keys · Cloudflare D1 docs

Foreign keys · Cloudflare D1 docs
D1 supports defining and enforcing foreign key constraints across tables in a database.
1 Reply
enkoder
enkoder8mo ago
Hey Matt, do I need to do anything in order to get defer_foreign_keys to work? I'm running "wrangler": "^3.28.4" and attempting to add PRAGMA defer_foreign_keys = true in my migration and I'm hitting an internal error.
workerd/util/symbolizer.c++:96: warning: Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set. To symbolize stack traces, set $LLVM_SYMBOLIZER to the location of the llvm-symbolizer binary. When running tests under bazel, use `--test_env=LLVM_SYMBOLIZER=<path>`.
workerd/jsg/util.c++:281: error: e = workerd/util/sqlite.c++:909: failed: SQLite failed; msg = FOREIGN KEY constraint failed; sqlite3_step()
stack: 105488ddf 1050c92db 1050ce013 1050ce3c7 106c3833f 1050c839f 104d951cc; sentryErrorContext = jsgInternalError
┌─────────────────┬────────┐
│ name │ status │
├─────────────────┼────────┤
│ 0009_opt-in.sql │ ❌ │
└─────────────────┴────────┘

❌ Migration 0009_opt-in.sql failed with the following errors:

✘ [ERROR] internal error
workerd/util/symbolizer.c++:96: warning: Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set. To symbolize stack traces, set $LLVM_SYMBOLIZER to the location of the llvm-symbolizer binary. When running tests under bazel, use `--test_env=LLVM_SYMBOLIZER=<path>`.
workerd/jsg/util.c++:281: error: e = workerd/util/sqlite.c++:909: failed: SQLite failed; msg = FOREIGN KEY constraint failed; sqlite3_step()
stack: 105488ddf 1050c92db 1050ce013 1050ce3c7 106c3833f 1050c839f 104d951cc; sentryErrorContext = jsgInternalError
┌─────────────────┬────────┐
│ name │ status │
├─────────────────┼────────┤
│ 0009_opt-in.sql │ ❌ │
└─────────────────┴────────┘

❌ Migration 0009_opt-in.sql failed with the following errors:

✘ [ERROR] internal error
OH! OK nice, I just wasn't ressing the value back to OFF which is why I was hitting the internal error. It worked!
Want results from more Discord servers?
Add your server