Skip to content

Instantly share code, notes, and snippets.

@DylanVerstraete
Created February 28, 2024 12:10
Show Gist options
  • Save DylanVerstraete/e4eb3267c4fbb32bd6c4f099f48a6f27 to your computer and use it in GitHub Desktop.
Save DylanVerstraete/e4eb3267c4fbb32bd6c4f099f48a6f27 to your computer and use it in GitHub Desktop.
for role in roles {
let postgres_pool = postgres_pool.clone();
let new_role_id = controllers::roles::create(
postgres_pool.clone(),
ModifiableRole {
name: role.name.clone(),
},
new_project_id,
)
.await?;
let permissions =
controllers::directory_permissions::get_all_for_role(postgres_pool.clone(), role.id)
.await?;
for permission in permissions {
// todo: get the path of the original directory of this permssion
// and attach this to the new directory (by path)
let _ = controllers::directory_permissions::create(
postgres_pool.clone(),
(
InsertableDirectoryPermissionDto {
// TODO: figure out how to get the directory_id for the new project
directory_id: permission.directory_id,
is_admin: permission.is_admin,
list: permission.list,
read: permission.read,
write: permission.write,
delete: permission.delete,
},
new_role_id,
),
)
.await?;
}
}
@DylanVerstraete
Copy link
Author

but these processes are seperate since copy is recursive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment