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
05b566ab
Commit
05b566ab
authored
Jun 08, 2021
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert migration causing timeouts on staging
parent
0f190487
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
64 deletions
+7
-64
db/post_migrate/20210526222715_backfill_draft_status_on_merge_requests.rb
...20210526222715_backfill_draft_status_on_merge_requests.rb
+7
-20
spec/migrations/backfill_draft_status_on_merge_requests_spec.rb
...igrations/backfill_draft_status_on_merge_requests_spec.rb
+0
-44
No files found.
db/post_migrate/20210526222715_backfill_draft_status_on_merge_requests.rb
View file @
05b566ab
# frozen_string_literal: true
class
BackfillDraftStatusOnMergeRequests
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
INDEX_NAME
=
"tmp_index_merge_requests_draft_and_status"
disable_ddl_transaction!
# include Gitlab::Database::MigrationHelpers
# Marking these as no-op as the original contents caused timeouts on
# staging. Removing the code here per
# #https://docs.gitlab.com/ee/development/deleting_migrations.html#how-to-disable-a-data-migration
# =>
def
up
add_concurrent_index
:merge_requests
,
:id
,
where:
"draft = false AND state_id = 1 AND ((title)::text ~* '^
\\
[draft
\\
]|
\\
(draft
\\
)|draft:|draft|
\\
[WIP
\\
]|WIP:|WIP'::text)"
,
name:
INDEX_NAME
update_column_in_batches
(
:merge_requests
,
:draft
,
true
,
batch_size:
100
)
do
|
table
,
query
|
query
.
where
(
table
[
:state_id
].
eq
(
1
))
.
where
(
table
[
:draft
].
eq
(
false
))
.
where
(
table
[
:title
].
matches_regexp
(
'^\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP'
,
false
))
end
remove_concurrent_index_by_name
:merge_requests
,
INDEX_NAME
# no-op
end
def
down
remove_concurrent_index_by_name
:merge_requests
,
INDEX_NAME
# no-op
end
end
spec/migrations/backfill_draft_status_on_merge_requests_spec.rb
deleted
100644 → 0
View file @
0f190487
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20210526222715_backfill_draft_status_on_merge_requests.rb'
)
RSpec
.
describe
BackfillDraftStatusOnMergeRequests
,
:migration
do
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:merge_requests
)
{
table
(
:merge_requests
)
}
let
(
:group
)
{
namespaces
.
create!
(
name:
'gitlab'
,
path:
'gitlab'
)
}
let
(
:project
)
{
projects
.
create!
(
namespace_id:
group
.
id
)
}
let
(
:draft_prefixes
)
{
[
"[Draft]"
,
"(Draft)"
,
"Draft:"
,
"Draft"
,
"[WIP]"
,
"WIP:"
,
"WIP"
]
}
def
create_merge_request
(
params
)
common_params
=
{
target_project_id:
project
.
id
,
target_branch:
'feature1'
,
source_branch:
'master'
}
merge_requests
.
create!
(
common_params
.
merge
(
params
))
end
context
"for MRs with #draft? == true titles but draft attribute false"
do
before
do
draft_prefixes
.
each
do
|
prefix
|
(
1
..
4
).
each
do
|
n
|
merge_request
=
create_merge_request
(
title:
"
#{
prefix
}
This is a title"
,
state_id:
n
)
merge_request
.
update_columns
(
draft:
false
)
end
end
end
it
"updates all open draft merge request's draft field to true"
do
mr_count
=
merge_requests
.
all
.
count
expect
{
disable_migrations_output
{
migrate!
}
}
.
to
change
{
MergeRequest
.
where
(
draft:
false
).
count
}
.
from
(
mr_count
).
to
(
mr_count
-
draft_prefixes
.
length
)
end
end
end
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