Skip to content

Conversation

calebbourg
Copy link
Collaborator

@calebbourg calebbourg commented Sep 16, 2025

Description

This PR adds a user_roles table that we will use to provide more granularity to our permissions scheme.

The user_roles table is associated with both the users table and, optionally, the organizations table. All users will have an associated user_roles.

As of this PR the available roles are:

  • User - default role
  • Admin - admin within the scope of an organization.
  • SuperAdmin - global admin.

Users with role Admin or User will have a user_roles record with role Admin or User respectively. the user_roles record will be scoped to the organization within which the user has that role.

Users with role SuperAdmin with have a user_roles record with role SuperAdmin and will not have an organization associated with their user_roles record.

Next up

  • Incorporating the new table into the API
  • Adding user_roles records for existing users
  • FE UI

GitHub Issue: [Closes|Fixes|Resolves] #185

Changes

  • Add user_roles table via migration
  • Add super_admin to enum type role
  • Add user_roles entity

Testing Strategy

rebuilding the db:

scripts/rebuild_db.sh

roll back migration

DATABASE_URL=postgres://refactor:password@localhost:5432/refactor sea-orm-cli migrate down -s refactor_platform

re-apply migration

DATABASE_URL=postgres://refactor:password@localhost:5432/refactor sea-orm-cli migrate up -s refactor_platform

Concerns

The migration is written mostly in Raw SQL. I opted for this as seaORM's documentation around migrations is still very lacking in actual usable examples. The main drawback here is portability between postgres and other database products should we ever want to switch. It's highly unlikely that that will ever happen.

You can write migration files in raw SQL, but then you lost the multi-backend compatibility SeaQuery offers.

@calebbourg calebbourg marked this pull request as ready for review September 16, 2025 11:20
@calebbourg calebbourg requested a review from jhodapp September 16, 2025 11:20
@calebbourg calebbourg self-assigned this Sep 16, 2025
@calebbourg calebbourg added feature work Specifically implementing a new feature bug fix Contains a fix to a known bug labels Sep 16, 2025
@calebbourg calebbourg added this to the 1.0.0-beta2 milestone Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix Contains a fix to a known bug feature work Specifically implementing a new feature
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant