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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
d741303a
Commit
d741303a
authored
Aug 19, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call `set_discussion_id` again in DiffNote `before_validation` because the order is important
parent
c711fe15
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
1 deletion
+31
-1
app/models/diff_note.rb
app/models/diff_note.rb
+3
-0
db/migrate/20160819221631_add_index_to_note_discussion_id.rb
db/migrate/20160819221631_add_index_to_note_discussion_id.rb
+14
-0
db/migrate/20160819221833_reset_diff_note_discussion_id_because_it_was_calculated_wrongly.rb
...f_note_discussion_id_because_it_was_calculated_wrongly.rb
+12
-0
db/schema.rb
db/schema.rb
+2
-1
No files found.
app/models/diff_note.rb
View file @
d741303a
...
...
@@ -16,6 +16,9 @@ class DiffNote < Note
after_initialize
:ensure_original_discussion_id
before_validation
:set_original_position
,
:update_position
,
on: :create
before_validation
:set_line_code
,
:set_original_discussion_id
# We need to do this again, because it's already in `Note`, but is affected by
# `update_position` and needs to run after that.
before_validation
:set_discussion_id
after_save
:keep_around_commits
class
<<
self
...
...
db/migrate/20160819221631_add_index_to_note_discussion_id.rb
0 → 100644
View file @
d741303a
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddIndexToNoteDiscussionId
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
change
add_concurrent_index
:notes
,
:discussion_id
end
end
db/migrate/20160819221833_reset_diff_note_discussion_id_because_it_was_calculated_wrongly.rb
0 → 100644
View file @
d741303a
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
ResetDiffNoteDiscussionIdBecauseItWasCalculatedWrongly
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
execute
"UPDATE notes SET discussion_id = NULL WHERE discussion_id IS NOT NULL AND type = 'DiffNote'"
end
end
db/schema.rb
View file @
d741303a
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2016081
8205718
)
do
ActiveRecord
::
Schema
.
define
(
version:
2016081
9221833
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -700,6 +700,7 @@ ActiveRecord::Schema.define(version: 20160818205718) do
add_index
"notes"
,
[
"author_id"
],
name:
"index_notes_on_author_id"
,
using: :btree
add_index
"notes"
,
[
"commit_id"
],
name:
"index_notes_on_commit_id"
,
using: :btree
add_index
"notes"
,
[
"created_at"
],
name:
"index_notes_on_created_at"
,
using: :btree
add_index
"notes"
,
[
"discussion_id"
],
name:
"index_notes_on_discussion_id"
,
using: :btree
add_index
"notes"
,
[
"line_code"
],
name:
"index_notes_on_line_code"
,
using: :btree
add_index
"notes"
,
[
"note"
],
name:
"index_notes_on_note_trigram"
,
using: :gin
,
opclasses:
{
"note"
=>
"gin_trgm_ops"
}
add_index
"notes"
,
[
"noteable_id"
,
"noteable_type"
],
name:
"index_notes_on_noteable_id_and_noteable_type"
,
using: :btree
...
...
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