Class: Namespace::Detail

Inherits:
ApplicationRecord show all
Defined in:
app/models/namespace/detail.rb

Overview

rubocop:disable Gitlab/BoundedContexts – TODO refactor to use bounded context

Constant Summary

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Instance Method Summary collapse

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, nullable_column?, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Instance Method Details

#add_creator(user) ⇒ Object

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 gitlab.com/gitlab-org/gitlab/-/merge_requests/82958/diffs#diff-content-c02244956d423e6837379548e5f9b1fa093bb289



20
21
22
# File 'app/models/namespace/detail.rb', line 20

def add_creator(user)
  update_attribute(:creator, user)
end