mirror of https://github.com/buster-so/buster.git
feat: Add organization_id to DatasetGroupPermission and update dataset group handler
- Introduced a new `organization_id` field in the `DatasetGroupPermission` struct to associate permissions with specific organizations. - Updated the `put_dataset_groups_handler` to include `organization_id` when creating or updating dataset group permissions, enhancing the API's capability to manage permissions at the organizational level. - Improved SQL query formatting for better readability in the handler.
This commit is contained in:
parent
1d8da61087
commit
ef5ca25810
|
@ -0,0 +1,3 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE dataset_groups_permissions
|
||||
DROP CONSTRAINT unique_dataset_group_permission;
|
|
@ -0,0 +1,4 @@
|
|||
-- Your SQL goes here
|
||||
ALTER TABLE dataset_groups_permissions
|
||||
ADD CONSTRAINT unique_dataset_group_permission
|
||||
UNIQUE (dataset_group_id, permission_id, permission_type);
|
|
@ -553,6 +553,7 @@ pub struct DatasetGroupPermission {
|
|||
pub dataset_group_id: Uuid,
|
||||
pub permission_id: Uuid,
|
||||
pub permission_type: String,
|
||||
pub organization_id: Uuid,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
pub deleted_at: Option<DateTime<Utc>>,
|
||||
|
|
|
@ -66,6 +66,7 @@ async fn put_dataset_groups_handler(
|
|||
dataset_group_id: group.id,
|
||||
permission_id: user_id,
|
||||
permission_type: "user".to_string(),
|
||||
organization_id: organization_id,
|
||||
deleted_at: None,
|
||||
created_at: chrono::Utc::now(),
|
||||
updated_at: chrono::Utc::now(),
|
||||
|
@ -80,7 +81,10 @@ async fn put_dataset_groups_handler(
|
|||
dataset_groups_permissions::permission_type,
|
||||
))
|
||||
.do_update()
|
||||
.set(dataset_groups_permissions::deleted_at.eq(None::<chrono::DateTime<chrono::Utc>>))
|
||||
.set(
|
||||
dataset_groups_permissions::deleted_at
|
||||
.eq(None::<chrono::DateTime<chrono::Utc>>),
|
||||
)
|
||||
.execute(&mut *conn)
|
||||
.await?;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue