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
79cc73c6
Commit
79cc73c6
authored
May 30, 2018
by
Chantal Rollison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add migration to remove commas from prior weight notes
parent
aa05be53
Changes
3
Show 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/db/migrate/20180530201303_remove_commas_from_weight_note.rb
.../migrate/20180530201303_remove_commas_from_weight_note.rb
+24
-0
ee/spec/migrations/remove_commas_from_weight_note_spec.rb
ee/spec/migrations/remove_commas_from_weight_note_spec.rb
+28
-0
No files found.
db/schema.rb
View file @
79cc73c6
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201805
29093006
)
do
ActiveRecord
::
Schema
.
define
(
version:
201805
30201303
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
...
ee/db/migrate/20180530201303_remove_commas_from_weight_note.rb
0 → 100644
View file @
79cc73c6
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
RemoveCommasFromWeightNote
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
ActiveRecord
::
Base
.
connection
.
execute
(
<<-
EOQ
)
UPDATE notes
SET notes.note = SUBSTRING(notes.note, 1, LEN(notes.note) - 1)
FROM system_note_metadata
WHERE system_note_metadata.note_id = notes.id AND notes.system AND system_note_metadata.action = 'weight' AND notes.note LIKE '%,'
EOQ
end
def
down
old_notes
=
Note
.
where
(
"note LIKE 'changed weight to%'"
)
old_notes
.
find_each
do
|
note
|
note
.
update_column
(
:note
,
note
.
note
.
concat
(
','
))
end
end
end
ee/spec/migrations/remove_commas_from_weight_note_spec.rb
0 → 100644
View file @
79cc73c6
require
'spec_helper'
require
Rails
.
root
.
join
(
'ee'
,
'db'
,
'migrate'
,
'../../db/migrate/20180530201303_remove_commas_from_weight_note.rb'
)
describe
RemoveCommasFromWeightNote
,
:migration
do
let
(
:migration
)
{
described_class
.
new
}
describe
'#up'
do
let
(
:notes
)
{
table
(
:notes
)}
let!
(
:note_1
)
{
notes
.
create
(
note:
'changed weight to 5,'
)}
let!
(
:note_2
)
{
notes
.
create
(
note:
'removed the weight'
)}
it
'removes all trailing commas'
do
expect
{
migrate!
}.
to
change
{
Note
.
where
(
"note LIKE '%,'"
).
count
}.
from
(
1
).
to
(
0
)
end
end
describe
'#down'
do
let
(
:notes
)
{
table
(
:notes
)}
let!
(
:note_1
)
{
notes
.
create
(
note:
'changed weight to 5'
)}
let!
(
:note_2
)
{
notes
.
create
(
note:
'removed the weight'
)}
it
'adds trailing commas'
do
expect
{
migration
.
down
}.
to
change
{
Note
.
where
(
"note LIKE '%,'"
).
count
}.
from
(
0
).
to
(
1
)
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