Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issuable_states.rb « concerns « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f0b9f0d1f3a8961848cd6c90869fe19fe1da82d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module IssuableStates
  extend ActiveSupport::Concern

  # The state:string column is being migrated to state_id:integer column
  # This is a temporary hook to keep state column in sync until it is removed.
  # Check https: https://gitlab.com/gitlab-org/gitlab/issues/33814 for more information
  # The state column can be safely removed after 2019-10-27
  included do
    before_save :sync_issuable_deprecated_state
  end

  def sync_issuable_deprecated_state
    return if self.is_a?(Epic)
    return unless respond_to?(:state)
    return if state_id.nil?

    deprecated_state = self.class.available_states.key(state_id)

    self.write_attribute(:state, deprecated_state)
  end
end