yesodweb / yesodweb/persistent
Incorrect ordering when dropping column and unique constraint at the same time
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
This is using the postgresql backend, but I'm not sure if this is backend-specific. Dropping a field called "rawBallot" from "Vote" results in:
Migrating: ALTER TABLE "vote" DROP COLUMN "raw_ballot"
Migrating: ALTER TABLE "vote" DROP CONSTRAINT "unique_ballot"
devel.hs: SqlError {sqlState = "42704", sqlExecStatus = FatalError, sqlErrorMsg = "constraint \"unique_ballot\" of relation \"vote\" does not exist", sqlErrorDetail = "", sqlErrorHint = ""}
Dropping the unique constraint fails, because dropping the column already implicitly dropped the constraint.
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 reproducing the PostgreSQL migration that drops rawBallot from Vote while removing unique_ballot, then trace the migration ordering that emits both ALTER TABLE statements. Done means the schema change succeeds without attempting to drop a constraint that PostgreSQL already removed, with regression coverage for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, postgresql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100