yesodweb / yesodweb/persistent

Postgres sqltype=varchar(n) causes remigration

Open
#454 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

If I have an existing database and put in the model:

 column Text Maybe sqltype=varchar(31)

it will cause Persistent to remigrate every run because it doesn't seem to recognize that it is the same as the existing type. Fixing it with:

column Text Maybe maxlen=31

is great and is the real fix, but it is very difficult to track this down and both should be the same thing and interchangeable. This can cause a failed migration when the column is part of a View in the db, for instance, and so altering the column type causes an sql error.

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 by reproducing the Persistent migration behavior with a PostgreSQL column declared as sqltype=varchar(31), then compare it with maxlen=31. Trace the schema type comparison and migration path; done means equivalent declarations no longer trigger remigration, including for columns used by a database view.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.