luckyframework / luckyframework/avram
Confusing error when running migrations with issues
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
If you have the following
```crystal
def migrate
create table_for(Comment) do
primary_key id : UUID
add_timestamps
add_belongs_to user : User, on_delete: :cascade
end
end
```
Then you run `lucky db.migrate`, you may run in to an error that mentions something like:
```
foreign key constraint "comment_user_id_fkey" cannot be implemented (Exception)
```
This is because the user id might be `UUID`, but you forgot to add the `foreign_key_type: UUID` to your `add_belongs_to`.
If we have a way to catch this error, we should.
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 at the migration path invoked by `lucky db.migrate` and inspect how `add_belongs_to` handles a UUID foreign key when `foreign_key_type` is omitted. Reproduce the example with `Comment` and `User`; done means the migration reports a clear, actionable error instead of the raw foreign-key constraint failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100