luckyframework / luckyframework/avram
remove_belongs_to throws error about fk constraint
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
When you want to remove a belongs_to, postgres will throw an error like:
> cannot drop column whatever because other objects depend on it
This is due to the foreign constraint keys. I think when we add `remove_belongs_to`, we need to also run something like:
```crystal
execute <<-SQL
ALTER TABLE things
DROP CONSTRAINT things_whatever_id_fkey
SQL
```
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 locating the remove_belongs_to migration entry point and reproduce the failure against PostgreSQL with a belongs_to foreign key. Confirm that removing the association also removes the foreign-key constraint and no longer raises the reported dependency error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal, postgresql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100