[go: up one dir, main page]

Skip to content

Add missing packages associations to User model

Context

The following grouppackage registry tables packages_composer_packages, packages_debian_group_distributions, packages_debian_project_distributions, and packages_packages have a foreign key to users table but User model doesn't have defined rails associations. This means the linked rows in the named tables won't be updated in the batch here that can have an impact on database timeouts details.

What does this MR do and why?

Add missing packages associations to User model

References

Create missing rails association for database r... (#571720)

Screenshots or screen recordings

No.

How to set up and validate locally

Execute the following commands in rails console

def fixture_file_upload(*args, **kwargs)
  Rack::Test::UploadedFile.new(*args, **kwargs)
end

project = Project.first
group = project.group
user = User.first

# packages_packages association
package = FactoryBot.create(:generic_package, project: project)
c = package.creator
c.packages # should return a package

# packages_composer_packages association
package = FactoryBot.create(:composer_package, project: project)
c = package.creator
c.composer_packages # should return a package

# packages_debian_group_distribution
gd = FactoryBot.create(:debian_group_distribution, group: group, creator: user)
c = gd.creator
c.debian_group_distributions # should return a group distribution

# packages_debian_project_distributions
pd = FactoryBot.create(:debian_project_distribution, project: project, creator: user)
c = pd.creator
c.debian_project_distributions # should return a project distribution

MR acceptance checklist

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

Related to #571720

Edited by Dzmitry (Dima) Meshcharakou

Merge request reports

Loading