yesodweb / yesodweb/persistent
Docs on Fixing Postgres Default Value Mismatches Is Incorrect
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes you'll write a model file that has a default attr like default=FALSE and get constant no-op migration suggestions because persistent is expecting your model definition to be default=false.
In the Quasi module docs(https://hackage-content.haskell.org/package/persistent-2.16.0.0/docs/Database-Persist-Quasi.html), there is a little blurb about using \d+ in psql to get the proper value to put in default= to make these go away.
But this is not always accurate, apparently psql does a little bit of cleanup when rendering the defaults. The real way is to mimic persistent's query(https://github.com/yesodweb/persistent/blob/9723907352a9ab98f2384c44f3c47e13ffa81af7/persistent-postgresql/Database/Persist/Postgresql.hs#L794-L809) and pull the value from there:
SELECT
column_default
FROM
information_schema.columns
WHERE
table_name='YOUR_TABLE_NAME'
AND
column_name='YOUR_COLUMN_NAME'
One example is psql showing a default of now() + '120 days'::interval while persistent expects an attr of default="(now() + '120 days'::interval)".
Would be nice to mention this other query in the persistent docs.
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 with the Database-Persist-Quasi documentation and compare its \d+ guidance with the query shown from persistent-postgresql/Database/Persist/Postgresql.hs. Update the documentation to mention querying information_schema.columns and retain the default-value example so readers know what correct guidance looks like.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, postgresql
- Domain
- databases, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100