Skip to content

Derive Project Namespace Organization from Project

Rutger Wessels requested to merge 411832-derive-project-ns-org-from-project into master

What does this MR do and why?

As part of Cells project, we are adding Organization as a required attribute for Namespaces.

This MR will assign the organization of the project to the ProjectNamespace that belongs to the project.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Use GDK and Rails Console gdk rails c:

# Create a new organization
org = Organizations::Organization.find_or_create_by(name: "My Org", path: 'my-org')

# Create a new project
project = Project.create!(organization: org, path: 'new-my-projects', name: 'My Project', namespace: Group.first, creator: User.first)

Namespaces::ProjectNamespace.create_from_project!(project)

# Most recent created Project Namespace refers to "My Org"
Namespaces::ProjectNamespace.last.organization.name

# Project namespace of Project refers to "My Org"
project.project_namespace.organization.name

Related to #411832

Edited by Rutger Wessels

Merge request reports