yesodweb / yesodweb/persistent
Possible problem with migrations and cascade behavior
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
using persistent-postgresql, a foreign key reference may not be acting correctly in the presence of CASCADE behavior
setup notes:
create table foo (id serial primary key, name text)create table bar (id serial primary key, foo_id integer references foo(id) on delete cascade)
Then with a model file like:
Foo
name String
Bar
fooId FooId
This will assume a default ON UPDATE RESTRICT ON DELETE RESTRICT, and will issue a migration. This migration should alter the constraint, not add one. I'm seeing a create statement locally.
Modifying the fooId field to be fooId FooId OnDelete Cascade is not dismissing that migration.
need to reproduce smaller.
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 migration with persistent-postgresql using the Foo and Bar schemas and the existing CASCADE foreign key described in the issue. Inspect the generated migration and the handling of OnDelete Cascade; done means it alters the existing constraint rather than issuing a create statement, and the migration is dismissed after the model matches the database.
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