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
1ea4b236
Commit
1ea4b236
authored
Jul 18, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add clean-up migration for RemoveCommaFromWeightSystemNotes
parent
d91899d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
1 deletion
+53
-1
db/schema.rb
db/schema.rb
+1
-1
ee/changelogs/unreleased/6793-clean-up-after-removecommafromweightsystemnotes-migration.yml
...n-up-after-removecommafromweightsystemnotes-migration.yml
+5
-0
ee/db/migrate/20180718100455_clean_up_from_weight_system_note_comma_migration.rb
...00455_clean_up_from_weight_system_note_comma_migration.rb
+47
-0
No files found.
db/schema.rb
View file @
1ea4b236
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201807
04204006
)
do
ActiveRecord
::
Schema
.
define
(
version:
201807
18100455
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
ee/changelogs/unreleased/6793-clean-up-after-removecommafromweightsystemnotes-migration.yml
0 → 100644
View file @
1ea4b236
---
title
:
Ensure no weight change system notes end with a superfluous comma
merge_request
:
6571
author
:
type
:
other
ee/db/migrate/20180718100455_clean_up_from_weight_system_note_comma_migration.rb
0 → 100644
View file @
1ea4b236
class
CleanUpFromWeightSystemNoteCommaMigration
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
MIGRATION
=
'RemoveCommaFromWeightSystemNotes'
.
freeze
BATCH_SIZE
=
1000
class
Note
<
ActiveRecord
::
Base
self
.
table_name
=
'notes'
include
::
EachBatch
end
disable_ddl_transaction!
def
up
Gitlab
::
BackgroundMigration
.
steal
(
MIGRATION
)
migrate_inline
if
weight_system_notes
.
any?
end
def
down
end
private
def
weight_system_notes
Note
.
joins
(
'INNER JOIN system_note_metadata ON notes.id = system_note_metadata.note_id'
)
.
where
(
system:
true
)
.
where
(
system_note_metadata:
{
action:
'weight'
})
.
where
(
"notes.note LIKE '%,'"
)
end
def
migrate_inline
add_concurrent_index
(
:system_note_metadata
,
:action
,
where:
"action = 'weight'"
)
weight_system_notes
.
each_batch
(
of:
BATCH_SIZE
)
do
|
relation
,
index
|
ids
=
relation
.
pluck
(
:id
)
Gitlab
::
BackgroundMigration
::
RemoveCommaFromWeightSystemNotes
.
new
.
perform
(
ids
)
end
remove_concurrent_index
(
:system_note_metadata
,
:action
,
where:
"action = 'weight'"
)
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