Level 1 boss: the signup system
Step 1 of 20%
Concept · step 1 of 2
The brief
A SaaS needs its accounts layer, and the product manager wrote it down. Read it like a spec: every sentence is a test on the next step.
- Users. sign up with an email, no two active users share one, deleting a user only stamps deleted_at, and a deleted user's email is free again.
- Organisations. each has a slug for its URL, and no two share one.
- Memberships. a user belongs to an organisation once, as owner, admin or member. Erasing a user removes their memberships; an organisation with members cannot be deleted, and that delete must stay fast.
- Invitations. sent to an email for an organisation, they expire after they are created, and an email has at most one pending invitation per organisation, but can be invited again once it accepted.
Every rule maps to something you have built in level 1: identity keys, a composite key, foreign keys and their delete actions, an index on a referencing column, CHECK across columns, partial unique indexes, and NULL meaning "not yet". Four tables, fourteen tests.
PostgreSQL docs: Constraints ↗Starting Postgres in your browser
About 5 MB the first time, cached after that.
PostgreSQL running in your browser