Commit f55eddb5 authored by Felipe Artur's avatar Felipe Artur Committed by Andreas Brandl

Rename epic column state to state_id

Rename epic column state to state_id to be consistent with
issues and merge requests
parent 51dd3df9
---
title: Rename epic column state to state_id
merge_request: 32270
author:
type: changed
# frozen_string_literal: true
class RenameEpicsStateToStateId < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
rename_column_concurrently :epics, :state, :state_id
end
def down
cleanup_concurrent_column_rename :epics, :state_id, :state
end
end
# frozen_string_literal: true
class CleanupEpicsStateIdRename < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
cleanup_concurrent_column_rename :epics, :state, :state_id
end
def down
rename_column_concurrently :epics, :state_id, :state
end
end
......@@ -1286,11 +1286,11 @@ ActiveRecord::Schema.define(version: 2019_08_28_083843) do
t.date "due_date_fixed"
t.boolean "start_date_is_fixed"
t.boolean "due_date_is_fixed"
t.integer "state", limit: 2, default: 1, null: false
t.integer "closed_by_id"
t.datetime "closed_at"
t.integer "parent_id"
t.integer "relative_position"
t.integer "state_id", limit: 2, default: 1, null: false
t.index ["assignee_id"], name: "index_epics_on_assignee_id"
t.index ["author_id"], name: "index_epics_on_author_id"
t.index ["closed_by_id"], name: "index_epics_on_closed_by_id"
......
......@@ -48,12 +48,12 @@ module Groups
preference = current_user.user_preference
if params[:state].present?
preference.roadmap_epics_state = Epic.states[params[:state]]
preference.roadmap_epics_state = Epic.state_ids[params[:state]]
preference.save if preference.changed? && Gitlab::Database.read_write?
end
Epic.states.key(preference.roadmap_epics_state)
Epic.state_ids.key(preference.roadmap_epics_state)
end
end
end
......@@ -14,7 +14,8 @@ module EE
include LabelEventable
include RelativePositioning
enum state: { opened: 1, closed: 2 }
enum state_id: { opened: 1, closed: 2 }
alias_attribute :state, :state_id
belongs_to :closed_by, class_name: 'User'
......
......@@ -6,7 +6,7 @@ module EE
prepended do
validates :roadmap_epics_state, allow_nil: true, inclusion: {
in: ::Epic.states.values, message: "%{value} is not a valid epic state"
in: ::Epic.state_ids.values, message: "%{value} is not a valid epic state id"
}
validates :epic_notes_filter, inclusion: { in: ::UserPreference::NOTES_FILTERS.values }, presence: true
......
......@@ -15,11 +15,11 @@ describe UserPreference do
describe 'roadmap_epics_state' do
context 'when set to open epics' do
it_behaves_like 'updates roadmap_epics_state', Epic.states[:opened]
it_behaves_like 'updates roadmap_epics_state', Epic.state_ids[:opened]
end
context 'when set to closed epics' do
it_behaves_like 'updates roadmap_epics_state', Epic.states[:closed]
it_behaves_like 'updates roadmap_epics_state', Epic.state_ids[:closed]
end
context 'when reset to all epics' do
......
......@@ -32,7 +32,7 @@ describe 'Database schema' do
draft_notes: %w[discussion_id commit_id],
emails: %w[user_id],
events: %w[target_id],
epics: %w[updated_by_id last_edited_by_id start_date_sourcing_milestone_id due_date_sourcing_milestone_id],
epics: %w[updated_by_id last_edited_by_id start_date_sourcing_milestone_id due_date_sourcing_milestone_id state_id],
forked_project_links: %w[forked_from_project_id],
geo_event_log: %w[hashed_storage_attachments_event_id],
geo_job_artifact_deleted_events: %w[job_artifact_id],
......
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