File: detail.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (28 lines) | stat: -rw-r--r-- 1,425 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

# rubocop:disable Gitlab/BoundedContexts -- TODO refactor to use bounded context
class Namespace::Detail < ApplicationRecord
  belongs_to :namespace, inverse_of: :namespace_details
  belongs_to :creator, class_name: "User", optional: true
  validates :namespace, presence: true
  validates :description, length: { maximum: 255 }

  ignore_column :pending_delete, remove_with: '17.7', remove_after: '2024-11-22'

  self.primary_key = :namespace_id

  # This method should not be called directly. Instead, it is available on the namespace via delegation and should
  # be called after the namespace is saved. Failure to do so will result in errors due to a database trigger that
  # automatically creates the namespace_details after a namespace is created. If we attempt to build the namespace
  # details before the namespace is saved, the trigger will fire and rails will subsequently try to create the
  # namespace_details which will result in an error due to a primary key conflict. Any other modifications to the
  # namespace details should be performed after the associated namespace is saved for the same reason.
  #
  # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82958/diffs#diff-content-c02244956d423e6837379548e5f9b1fa093bb289
  def add_creator(user)
    update_attribute(:creator, user)
  end
end
# rubocop:enable Gitlab/BoundedContexts

Namespace::Detail.prepend_mod