Skip to content

Commit

Permalink
Don't create root workspace in database in migration tool
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Aug 28, 2024
1 parent 59854c1 commit ec963a6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rbac/migration_tool/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ def migrate_role(role: Role, write_db: bool, root_workspace: str, default_worksp

def migrate_workspace(tenant: Tenant, write_db: bool):
"""Migrate a workspace from v1 to v2."""
root_workspace = Workspace.objects.create(name="root", description="Root workspace", tenant=tenant)
root_workspace = f"root-workspace-{tenant.org_id}"
# Org id represents the default workspace for now
relationships = [
create_relationship("workspace", tenant.org_id, "workspace", str(root_workspace.uuid), "parent"),
create_relationship("workspace", str(root_workspace.uuid), "tenant", tenant.org_id, "parent"),
create_relationship("workspace", tenant.org_id, "workspace", root_workspace, "parent"),
create_relationship("workspace", root_workspace, "tenant", tenant.org_id, "parent"),
]
# Include realm for tenant
relationships.append(create_relationship("tenant", str(tenant.org_id), "realm", settings.ENV_NAME, "realm"))
output_relationships(relationships, write_db)
return str(root_workspace.uuid), tenant.org_id
return root_workspace, tenant.org_id


def migrate_users(tenant: Tenant, write_db: bool):
Expand Down

0 comments on commit ec963a6

Please sign in to comment.