yesodweb / yesodweb/persistent
Self Reference foreign keys are not generated
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
A migration like this:
Chain
previousChain ChainId Maybe
deriving Show Eq
will fail to generate any foreign keys at postgreSQL. I have narrowed down the bug to the getAddReference function, at the guard guard $ table /= s && cname /= fieldDB (entityId entity), especially the first check. Removing that fixes the problem. I think the check was added for the sql=id option https://github.com/yesodweb/persistent/pull/1066, so simply removing it may break other stuff?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the getAddReference function and inspect the guard involving table, cname, and fieldDB (entityId entity). Compare its behavior with the sql=id change discussed in pull request 1066, using the self-referencing Chain migration as the reproduction. Done means self-reference foreign keys are generated for PostgreSQL without regressing the sql=id behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100