Skip to content

Commit

Permalink
Merge pull request #1964 from fractal-analytics-platform/1959-review-…
Browse files Browse the repository at this point in the history
…assumption-on-single-group-in-data-migration-script

Fix `where` in create-first-group function
  • Loading branch information
tcompa authored Oct 24, 2024
2 parents 9cf8ee8 + cb5b5a2 commit 4935eaf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
* Introduce `FractalSSH.fetch_file` and `FractalSSH.read_remote_json_file` (\#1949).
* Use `paramiko.sftp_client.SFTPClient` methods directly rathen than `fabric` wrappers (\#1949).
* Disable prefetching for `SFTPClient.get` (\#1949).
* Internal:
* Update `_create_first_group` so that it only searches for `UserGroups` with a given name (\#1964).
* Dependencies:
* Bump fastapi to `0.115` (\#1942).
* Testing:
Expand Down
9 changes: 8 additions & 1 deletion fractal_server/app/security/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,20 @@ async def _create_first_user(


def _create_first_group():
"""
Create a `UserGroup` with `name=FRACTAL_DEFAULT_GROUP_NAME`, if missing.
"""
function_logger = set_logger("fractal_server.create_first_group")

function_logger.info(
f"START _create_first_group, with name '{FRACTAL_DEFAULT_GROUP_NAME}'"
)
with next(get_sync_db()) as db:
group_all = db.execute(select(UserGroup))
group_all = db.execute(
select(UserGroup).where(
UserGroup.name == FRACTAL_DEFAULT_GROUP_NAME
)
)
if group_all.scalars().one_or_none() is None:
first_group = UserGroup(name=FRACTAL_DEFAULT_GROUP_NAME)
db.add(first_group)
Expand Down

0 comments on commit 4935eaf

Please sign in to comment.