yesodweb / yesodweb/persistent

Incorrect ordering when dropping column and unique constraint at the same time

Open
#486 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Newcomer Postgres
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.