Commit 854eb4be authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'ab-49609-internal-ids-require-init' into 'master'

Require has_internal_id to pass a init block.

Closes #49609

See merge request gitlab-org/gitlab-ce!20873
parents 31a4f48c 90778e5d
...@@ -26,6 +26,10 @@ module AtomicInternalId ...@@ -26,6 +26,10 @@ module AtomicInternalId
module ClassMethods module ClassMethods
def has_internal_id(column, scope:, init:, presence: true) # rubocop:disable Naming/PredicateName def has_internal_id(column, scope:, init:, presence: true) # rubocop:disable Naming/PredicateName
# We require init here to retain the ability to recalculate in the absence of a
# InternaLId record (we may delete records in `internal_ids` for example).
raise "has_internal_id requires a init block, none given." unless init
before_validation :"ensure_#{scope}_#{column}!", on: :create before_validation :"ensure_#{scope}_#{column}!", on: :create
validates column, presence: presence validates column, presence: presence
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment