luckyframework / luckyframework/avram
Schema validator for has_one and unique
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
If you make a migration using add_belongs_to user : User, and that user only has_one of this object, then it would make sense that you'd want to also make sure this add_belongs_to has the unique: true set. Without it, it's possible to have more than 1 record even though you specify has_one.
This might be a good chance to add a new SchemaEnforcer validation that if your model has_one, the other model should have the belongs_to with a unique index on it.
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 with the SchemaEnforcer validation path and how add_belongs_to handles relationship and unique-index options. Done means a has_one relationship is checked for a corresponding belongs_to with a unique index, with validation coverage for the migration scenario described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal, postgresql
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100