Skip to main content

safe_migrate/model/
role.rs

1use crate::ast::identifiers::ObjectId;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5pub enum Privilege {
6    Select,
7    Insert,
8    Update,
9    Delete,
10    Truncate,
11    References,
12    Trigger,
13    All,
14}
15
16#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
17pub struct PrivilegeGrant {
18    pub on: ObjectId,               // table/schema/database the grant targets
19    pub privileges: Vec<Privilege>, // SELECT, INSERT, UPDATE, DELETE, ALL, etc.
20    pub grantee: ObjectId,          // the role receiving it
21    pub with_grant_option: bool,
22}
23
24#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
25pub struct RoleState {
26    pub id: ObjectId, // role name, no schema
27    pub can_login: bool,
28    pub is_superuser: bool,
29    pub member_of: Vec<ObjectId>, // roles this role inherits from
30    pub granted_privileges: Vec<PrivilegeGrant>,
31}
32
33#[derive(Debug, Clone, PartialEq)]
34pub enum RoleOverlay {
35    Present(RoleState),
36    Dropped,
37}