Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a0856171
Commit
a0856171
authored
Feb 19, 2020
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove state column from issues and merge_requests
safely removes state column from issues and merge_requests
parent
a6f35904
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
146 additions
and
13 deletions
+146
-13
app/models/issue.rb
app/models/issue.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
changelogs/unreleased/drop_old_state_column_from_issues.yml
changelogs/unreleased/drop_old_state_column_from_issues.yml
+5
-0
db/post_migrate/20200219183456_remove_issue_state_indexes.rb
db/post_migrate/20200219183456_remove_issue_state_indexes.rb
+40
-0
db/post_migrate/20200219184219_remove_merge_request_state_indexes.rb
...rate/20200219184219_remove_merge_request_state_indexes.rb
+39
-0
db/post_migrate/20200219193058_remove_state_from_issues.rb
db/post_migrate/20200219193058_remove_state_from_issues.rb
+30
-0
db/post_migrate/20200219193117_remove_state_from_merge_requests.rb
...igrate/20200219193117_remove_state_from_merge_requests.rb
+30
-0
db/schema.rb
db/schema.rb
+0
-11
No files found.
app/models/issue.rb
View file @
a0856171
...
...
@@ -77,7 +77,7 @@ class Issue < ApplicationRecord
scope
:counts_by_state
,
->
{
reorder
(
nil
).
group
(
:state_id
).
count
}
ignore_column
:state
,
remove_with:
'12.
7'
,
remove_after:
'2019-12
-22'
ignore_column
:state
,
remove_with:
'12.
10'
,
remove_after:
'2020-03
-22'
after_commit
:expire_etag_cache
,
unless: :importing?
after_save
:ensure_metrics
,
unless: :importing?
...
...
app/models/merge_request.rb
View file @
a0856171
...
...
@@ -261,7 +261,7 @@ class MergeRequest < ApplicationRecord
includes
(
:metrics
)
end
ignore_column
:state
,
remove_with:
'12.
7'
,
remove_after:
'2019-12
-22'
ignore_column
:state
,
remove_with:
'12.
10'
,
remove_after:
'2020-03
-22'
after_save
:keep_around_commit
,
unless: :importing?
...
...
changelogs/unreleased/drop_old_state_column_from_issues.yml
0 → 100644
View file @
a0856171
---
title
:
Remove state column from issues and merge_requests
merge_request
:
25561
author
:
type
:
deprecated
db/post_migrate/20200219183456_remove_issue_state_indexes.rb
0 → 100644
View file @
a0856171
# frozen_string_literal: true
class
RemoveIssueStateIndexes
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
# issues state column is ignored since 12.6 and will be removed on a following migration
def
up
remove_concurrent_index_by_name
:issues
,
'index_issues_on_state'
remove_concurrent_index_by_name
:issues
,
'index_issues_on_project_id_and_created_at_and_id_and_state'
remove_concurrent_index_by_name
:issues
,
'idx_issues_on_project_id_and_due_date_and_id_and_state_partial'
remove_concurrent_index_by_name
:issues
,
'index_issues_on_project_id_and_rel_position_and_state_and_id'
remove_concurrent_index_by_name
:issues
,
'index_issues_on_project_id_and_updated_at_and_id_and_state'
end
def
down
add_concurrent_index
:issues
,
:state
,
name:
'index_issues_on_state'
add_concurrent_index
:issues
,
[
:project_id
,
:created_at
,
:id
,
:state
],
name:
'index_issues_on_project_id_and_created_at_and_id_and_state'
add_concurrent_index
:issues
,
[
:project_id
,
:due_date
,
:id
,
:state
],
where:
'due_date IS NOT NULL'
,
name:
'idx_issues_on_project_id_and_due_date_and_id_and_state_partial'
add_concurrent_index
:issues
,
[
:project_id
,
:relative_position
,
:state
,
:id
],
order:
{
id: :desc
},
name:
'index_issues_on_project_id_and_rel_position_and_state_and_id'
add_concurrent_index
:issues
,
[
:project_id
,
:updated_at
,
:id
,
:state
],
name:
'index_issues_on_project_id_and_updated_at_and_id_and_state'
end
end
db/post_migrate/20200219184219_remove_merge_request_state_indexes.rb
0 → 100644
View file @
a0856171
# frozen_string_literal: true
class
RemoveMergeRequestStateIndexes
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
# merge_requests state column is ignored since 12.6 and will be removed on a following migration
def
up
remove_concurrent_index_by_name
:merge_requests
,
'index_merge_requests_on_id_and_merge_jid'
remove_concurrent_index_by_name
:merge_requests
,
'index_merge_requests_on_source_project_and_branch_state_opened'
remove_concurrent_index_by_name
:merge_requests
,
'index_merge_requests_on_state_and_merge_status'
remove_concurrent_index_by_name
:merge_requests
,
'index_merge_requests_on_target_project_id_and_iid_opened'
end
def
down
add_concurrent_index
:merge_requests
,
[
:id
,
:merge_jid
],
where:
"merge_jid IS NOT NULL and state = 'locked'"
,
name:
'index_merge_requests_on_id_and_merge_jid'
add_concurrent_index
:merge_requests
,
[
:source_project_id
,
:source_branch
],
where:
"state = 'opened'"
,
name:
'index_merge_requests_on_source_project_and_branch_state_opened'
add_concurrent_index
:merge_requests
,
[
:state
,
:merge_status
],
where:
"state = 'opened' AND merge_status = 'can_be_merged'"
,
name:
'index_merge_requests_on_state_and_merge_status'
add_concurrent_index
:merge_requests
,
[
:target_project_id
,
:iid
],
where:
"state = 'opened'"
,
name:
'index_merge_requests_on_target_project_id_and_iid_opened'
end
end
db/post_migrate/20200219193058_remove_state_from_issues.rb
0 → 100644
View file @
a0856171
# frozen_string_literal: true
class
RemoveStateFromIssues
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
return
unless
issue_state_column_exists?
# Ignored in 12.6 - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/19574
with_lock_retries
do
remove_column
:issues
,
:state
,
:string
end
end
def
down
return
if
issue_state_column_exists?
with_lock_retries
do
add_column
:issues
,
:state
,
:string
# rubocop:disable Migration/AddLimitToStringColumns
end
end
private
def
issue_state_column_exists?
column_exists?
(
:issues
,
:state
)
end
end
db/post_migrate/20200219193117_remove_state_from_merge_requests.rb
0 → 100644
View file @
a0856171
# frozen_string_literal: true
class
RemoveStateFromMergeRequests
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
return
unless
merge_requests_state_column_exists?
# Ignored in 12.6 - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/19574
with_lock_retries
do
remove_column
:merge_requests
,
:state
,
:string
end
end
def
down
return
if
merge_requests_state_column_exists?
with_lock_retries
do
add_column
:merge_requests
,
:state
,
:string
# rubocop:disable Migration/AddLimitToStringColumns
end
end
private
def
merge_requests_state_column_exists?
column_exists?
(
:merge_requests
,
:state
)
end
end
db/schema.rb
View file @
a0856171
...
...
@@ -2184,7 +2184,6 @@ ActiveRecord::Schema.define(version: 2020_03_11_165635) do
t
.
datetime
"updated_at"
t
.
text
"description"
t
.
integer
"milestone_id"
t
.
string
"state"
t
.
integer
"iid"
t
.
integer
"updated_by_id"
t
.
integer
"weight"
...
...
@@ -2216,18 +2215,13 @@ ActiveRecord::Schema.define(version: 2020_03_11_165635) do
t
.
index
[
"lock_version"
],
name:
"index_issues_on_lock_version"
,
where:
"(lock_version IS NULL)"
t
.
index
[
"milestone_id"
],
name:
"index_issues_on_milestone_id"
t
.
index
[
"moved_to_id"
],
name:
"index_issues_on_moved_to_id"
,
where:
"(moved_to_id IS NOT NULL)"
t
.
index
[
"project_id"
,
"created_at"
,
"id"
,
"state"
],
name:
"index_issues_on_project_id_and_created_at_and_id_and_state"
t
.
index
[
"project_id"
,
"created_at"
,
"id"
,
"state_id"
],
name:
"idx_issues_on_project_id_and_created_at_and_id_and_state_id"
t
.
index
[
"project_id"
,
"due_date"
,
"id"
,
"state"
],
name:
"idx_issues_on_project_id_and_due_date_and_id_and_state_partial"
,
where:
"(due_date IS NOT NULL)"
t
.
index
[
"project_id"
,
"due_date"
,
"id"
,
"state_id"
],
name:
"idx_issues_on_project_id_and_due_date_and_id_and_state_id"
,
where:
"(due_date IS NOT NULL)"
t
.
index
[
"project_id"
,
"iid"
],
name:
"index_issues_on_project_id_and_iid"
,
unique:
true
t
.
index
[
"project_id"
,
"relative_position"
,
"state"
,
"id"
],
name:
"index_issues_on_project_id_and_rel_position_and_state_and_id"
,
order:
{
id: :desc
}
t
.
index
[
"project_id"
,
"relative_position"
,
"state_id"
,
"id"
],
name:
"idx_issues_on_project_id_and_rel_position_and_state_id_and_id"
,
order:
{
id: :desc
}
t
.
index
[
"project_id"
,
"updated_at"
,
"id"
,
"state"
],
name:
"index_issues_on_project_id_and_updated_at_and_id_and_state"
t
.
index
[
"project_id"
,
"updated_at"
,
"id"
,
"state_id"
],
name:
"idx_issues_on_project_id_and_updated_at_and_id_and_state_id"
t
.
index
[
"promoted_to_epic_id"
],
name:
"index_issues_on_promoted_to_epic_id"
,
where:
"(promoted_to_epic_id IS NOT NULL)"
t
.
index
[
"relative_position"
],
name:
"index_issues_on_relative_position"
t
.
index
[
"state"
],
name:
"index_issues_on_state"
t
.
index
[
"state_id"
],
name:
"idx_issues_on_state_id"
t
.
index
[
"title"
],
name:
"index_issues_on_title_trigram"
,
opclass: :gin_trgm_ops
,
using: :gin
t
.
index
[
"updated_at"
],
name:
"index_issues_on_updated_at"
...
...
@@ -2597,7 +2591,6 @@ ActiveRecord::Schema.define(version: 2020_03_11_165635) do
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
integer
"milestone_id"
t
.
string
"state"
,
default:
"opened"
,
null:
false
t
.
string
"merge_status"
,
default:
"unchecked"
,
null:
false
t
.
integer
"target_project_id"
,
null:
false
t
.
integer
"iid"
...
...
@@ -2633,7 +2626,6 @@ ActiveRecord::Schema.define(version: 2020_03_11_165635) do
t
.
index
[
"description"
],
name:
"index_merge_requests_on_description_trigram"
,
opclass: :gin_trgm_ops
,
using: :gin
t
.
index
[
"head_pipeline_id"
],
name:
"index_merge_requests_on_head_pipeline_id"
t
.
index
[
"id"
,
"merge_jid"
],
name:
"idx_merge_requests_on_id_and_merge_jid"
,
where:
"((merge_jid IS NOT NULL) AND (state_id = 4))"
t
.
index
[
"id"
,
"merge_jid"
],
name:
"index_merge_requests_on_id_and_merge_jid"
,
where:
"((merge_jid IS NOT NULL) AND ((state)::text = 'locked'::text))"
t
.
index
[
"id"
],
name:
"merge_request_mentions_temp_index"
,
where:
"((description ~~ '%@%'::text) OR ((title)::text ~~ '%@%'::text))"
t
.
index
[
"latest_merge_request_diff_id"
],
name:
"index_merge_requests_on_latest_merge_request_diff_id"
t
.
index
[
"lock_version"
],
name:
"index_merge_requests_on_lock_version"
,
where:
"(lock_version IS NULL)"
...
...
@@ -2641,15 +2633,12 @@ ActiveRecord::Schema.define(version: 2020_03_11_165635) do
t
.
index
[
"milestone_id"
],
name:
"index_merge_requests_on_milestone_id"
t
.
index
[
"source_branch"
],
name:
"index_merge_requests_on_source_branch"
t
.
index
[
"source_project_id"
,
"source_branch"
],
name:
"idx_merge_requests_on_source_project_and_branch_state_opened"
,
where:
"(state_id = 1)"
t
.
index
[
"source_project_id"
,
"source_branch"
],
name:
"index_merge_requests_on_source_project_and_branch_state_opened"
,
where:
"((state)::text = 'opened'::text)"
t
.
index
[
"source_project_id"
,
"source_branch"
],
name:
"index_merge_requests_on_source_project_id_and_source_branch"
t
.
index
[
"state"
,
"merge_status"
],
name:
"index_merge_requests_on_state_and_merge_status"
,
where:
"(((state)::text = 'opened'::text) AND ((merge_status)::text = 'can_be_merged'::text))"
t
.
index
[
"state_id"
,
"merge_status"
],
name:
"idx_merge_requests_on_state_id_and_merge_status"
,
where:
"((state_id = 1) AND ((merge_status)::text = 'can_be_merged'::text))"
t
.
index
[
"target_branch"
],
name:
"index_merge_requests_on_target_branch"
t
.
index
[
"target_project_id"
,
"created_at"
],
name:
"index_merge_requests_target_project_id_created_at"
t
.
index
[
"target_project_id"
,
"iid"
],
name:
"idx_merge_requests_on_target_project_id_and_iid_opened"
,
where:
"(state_id = 1)"
t
.
index
[
"target_project_id"
,
"iid"
],
name:
"index_merge_requests_on_target_project_id_and_iid"
,
unique:
true
t
.
index
[
"target_project_id"
,
"iid"
],
name:
"index_merge_requests_on_target_project_id_and_iid_opened"
,
where:
"((state)::text = 'opened'::text)"
t
.
index
[
"target_project_id"
,
"merge_commit_sha"
,
"id"
],
name:
"index_merge_requests_on_tp_id_and_merge_commit_sha_and_id"
t
.
index
[
"target_project_id"
,
"target_branch"
],
name:
"index_merge_requests_on_target_project_id_and_target_branch"
,
where:
"((state_id = 1) AND (merge_when_pipeline_succeeds = true))"
t
.
index
[
"title"
],
name:
"index_merge_requests_on_title"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment