diff --git a/rbac/migration_tool/migrate.py b/rbac/migration_tool/migrate.py index e35aa1991..78cb6aa5a 100644 --- a/rbac/migration_tool/migrate.py +++ b/rbac/migration_tool/migrate.py @@ -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):