luckyframework / luckyframework/avram

Schema validator for has_one and unique

Open
#839 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.