Ithibati.Bootstrap (Ithibati v0.1.0)

Copy Markdown View Source

The record that an instance has been set up, and by whom.

A row here is the claim, and there can be at most one. This is a table of Ithibati's rather than a flag on the account for two reasons, and the second one decides it.

The application would have to create the flag itself, on a table Ithibati does not own, together with a partial unique index that is the entire guarantee. Forgetting that index fails nothing until two people register at the same moment. Here Ithibati.Migration.up/1 creates the index, so nobody can forget it.

A boolean on an account also conflates two different facts: this instance has been set up and this account set it up. Delete that account and both vanish, which makes a second setup possible again. user_id is nullable and nilified on delete, so the row goes on saying that the instance is set up even when the account that set it up is gone.

Summary

Functions

Claims the instance for an account.

Functions

changeset(bootstrap, attrs)

Claims the instance for an account.

Insert it and read the outcome. The second caller of two gets an error on :claimed, which is what tells "somebody else was first" apart from "this form is wrong".