hey folks. How would I go about modeling a "site l...
# help
n
hey folks. How would I go about modeling a "site license" in supabase/postgres? That is, a license which is valid for any user in the users table whose email matches
*@whatever.com
?
k
How often will users sign up, compared to license checks?
I'd probably add users to sites/organizations on sign-up (maybe even have a many to many relation between sites and users, depending on product), and only do license checks out of band. Most of the time it's good enough to catch sites getting a few users too many once a day (for notification), or even once a month (for accounting, and maybe a call to a growing client)
If you need a hard limit, then you will need a lock - but even locking a row for each site at user registration time is not that bad - I mean, how many users will try to register at the same second?
n
i would bet this will be small number of users + licenses + queries for a while
new company/project 🙂
I like that... how would I add users to sites/organizations at sign-up?
(I mean, is that something I can configure supabase to automatically write? Or would this be a few manual steps using the supabase client lib during the auth flow)
k
Triggers shold work if you can do this automatically and with no expected exceptions - you should be able to add a trigger to auth.users. Another good way would be a "welcome to the app, please fill your profile" screen that calls a procedure in supabase (through the rpc interface). Then you can get any additional data you need, fill a user's profile table and set up a relationship between user and an organisation there.
n
Ok great, thanks!