Skip to content

Cross-table invariants #84

Description

@gammelalf

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions