yesodweb / yesodweb/persistent

Two same named sql table models should throw a migration error

Open
#1,470 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

say I've a model A:

A sql=same_name
  Id UUID
  myText Text

and a model B with the same sql name as A

B sql=same_name
  Id UUID

this will first tell me to:

ALTER TABLE "same_name" ADD COLUMN "my_text" VARCHAR NOT NULL;

and then once I do that, it will tell me to:

ALTER TABLE "same_name" DROP "my_text";

which is a cute little dance,
but in this case i'd expect persistent to tell me we shouldn't doubly map a model to the same sql backend.

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

The issue provides no file or test entry point; start by reproducing the two models with the shared SQL name and trace the migration-generation path. Done means the migration process reports a duplicate model-to-table mapping error instead of proposing alternating ADD and DROP statements.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, sql
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.