yesodweb / yesodweb/persistent

Broken migrations report errors using `error`, making handling/introspection difficult

Open
#1,461 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

Sanity checking/resolution of foreign references happens at runtime when using migrateModels, unfortunately there is no explicit error handling if there is an error in the model (see:
https://github.com/yesodweb/persistent/blob/bea20181d1f70f0b01e1cb4214c422c8189626c6/persistent/Database/Persist/Sql/Internal.hs#L201).

I'm trying to debug/report where the model is broken, but I have no real way to "catch" the broken/missing table and lookup which offending model entity is referencing the missing table, which makes debugging broken models kind of a pain.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with migrateModels and the referenced code in persistent/Database/Persist/Sql/Internal.hs around line 201, then trace how broken or missing foreign references are reported. Done should provide explicit, catchable error information that identifies the offending model entity and missing table.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.