Apexal / rcos_io

The final RCOS web client. Built on the RCOS database via Hasura.
MIT License
3 stars 1 forks source link

Database QoL Enhancements #12

Open Apexal opened 1 year ago

Apexal commented 1 year ago

Using Postgres and Hasura provides us with really cool tools to keep our data clean and organized with less code.

For example, we wouldn't want a user to be able to be marked as a project lead while not being assigned to a project. We could check for this in the site code when we make changes to the user's enrollment, but this is extra code and doesn't cover cases where data might be changed by other programs like a Discord bot.

Another example is determining a user's display name when the might have limited data available (first name but not last name, only first name, no names but rcs id, no names or rcs id, etc.). We can write a Python functions that takes in a user and determines the display name, but we probably want to use that functionality across more than just the site.

Instead, we can use Postgres constraints, triggers, functions and Hasura computed fields (as well as other features) to centralize some of that validation and helper logic in the database itself!

Suggested ideas:

These would generally be written in SQL and have to be kept somewhere in source control. We would probably use Hasura SQL migrations and a repository like rcos/rcos-data which is currently being used for the self-hosted Hasura instance on DigitalOcean. We should discuss where this SQL would go, but in the meantime the work figuring out the SQL for these items can be done.