Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-table invariants #84

Open
gammelalf opened this issue Feb 17, 2025 · 0 comments
Open

Cross-table invariants #84

gammelalf opened this issue Feb 17, 2025 · 0 comments

Comments

@gammelalf
Copy link
Member

I want to properly represent invariants about my models.

With invariants I mean properties of the inserted models which should always be true (or at least outside of a transaction).

In parts this could be represented by sql constraints. But this is hard accross DBs especially with constraints which would affect multiple tables. On top of that, sql constraints, usually, must hold even inside of a transaction. (I might be ignorant to some fancy sql features)

What do I expect from such a feature:

  • it should help with refactoring:
    • new code which violates the invariant should not compile (HARD)
    • old code which depended on a removed invariant should not compile (hopefully not so hard)
  • invariants should be readable as documentation
  • invariants should be checkable:
    • at program startup
    • in regular intervals
    • in assertions (maybe at the end of each transaction; maybe using hooks CRUD hooks #83)

I plan to implement inner table invariants (what could be represented with constraints) using #79 and new types.
(But it is not necessarily the only implementation of it)

(This could also be a galvyn feature built on top of #83)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant