yesodweb / yesodweb/persistent
Postgres migrations: Changing foreign key constraint does not trigger migration
Open
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
When changing a foreign key constraint, e.g. from
PTH.share [PTH.mkPersist PTH.sqlSettings, PTH.mkEntityDefList "entities" ] [PTH.persistLowerCase|
Parent sql=parent
number Int
year Int
Primary number year
deriving Show Read
Child sql=child
number Int
year Int
version Int
Primary number year version
Foreign Parent fk number year
deriving Show Read
|]
to
PTH.share [PTH.mkPersist PTH.sqlSettings, PTH.mkEntityDefList "entities" ] [PTH.persistLowerCase|
Parent sql=parent
number Int
year Int
Primary number year
deriving Show Read
Child sql=child
number Int
year Int
version Int
Primary number year version
Foreign Parent OnDeleteCascade fk number year
deriving Show Read
|]
no migrations are triggered from
migrateAll :: Migration
migrateAll = migrateModels entities
Am I missing something here, in order to get the proper fkey update?
I am using the postgres backend.
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 change from the issue's Parent and Child definitions using the PostgreSQL backend and migrateAll = migrateModels entities. Trace how migrateModels compares foreign-key definitions, especially the added OnDeleteCascade option. Done means changing the constraint generates and applies the expected foreign-key migration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100