1
0
Fork 0
forked from 2sys/phonograph
phonograph/mdengine/src/table_privileges.rs

28 lines
1.2 KiB
Rust
Raw Normal View History

2025-05-13 00:02:33 -07:00
use diesel::{pg::Pg, prelude::*};
2025-05-02 23:48:54 -07:00
2025-05-13 00:02:33 -07:00
use crate::schema::table_privileges;
2025-05-02 23:48:54 -07:00
2025-05-13 00:02:33 -07:00
pub use crate::schema::table_privileges::{dsl, table};
2025-05-02 23:48:54 -07:00
#[derive(Clone, Debug, Queryable, Selectable)]
2025-05-13 00:02:33 -07:00
#[diesel(check_for_backend(Pg))]
2025-05-02 23:48:54 -07:00
#[diesel(table_name = table_privileges)]
pub struct TablePrivilege {
/// Name of the role that granted the privilege
2025-05-13 00:02:33 -07:00
pub grantor: String,
2025-05-02 23:48:54 -07:00
/// Name of the role that the privilege was granted to
2025-05-13 00:02:33 -07:00
pub grantee: String,
2025-05-02 23:48:54 -07:00
/// Name of the database that contains the table (always the current database)
2025-05-13 00:02:33 -07:00
pub table_catalog: String,
2025-05-02 23:48:54 -07:00
/// Name of the schema that contains the table
2025-05-13 00:02:33 -07:00
pub table_schema: String,
2025-05-02 23:48:54 -07:00
/// Name of the table
2025-05-13 00:02:33 -07:00
pub table_name: String,
2025-05-02 23:48:54 -07:00
/// Type of the privilege: SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, or TRIGGER
2025-05-13 00:02:33 -07:00
pub privilege_type: String,
2025-05-02 23:48:54 -07:00
/// YES if the privilege is grantable, NO if not
2025-05-13 00:02:33 -07:00
pub is_grantable: String,
2025-05-02 23:48:54 -07:00
/// In the SQL standard, WITH HIERARCHY OPTION is a separate (sub-)privilege allowing certain operations on table inheritance hierarchies. In PostgreSQL, this is included in the SELECT privilege, so this column shows YES if the privilege is SELECT, else NO.
2025-05-13 00:02:33 -07:00
pub with_hierarchy: String,
2025-05-02 23:48:54 -07:00
}