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
e96624b0
Commit
e96624b0
authored
Dec 12, 2019
by
Alexandru Croitor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change commit_id type on commit_user_mentions table
Change commit_id column type from binary to string.
parent
a98b8302
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
2 deletions
+68
-2
changelogs/unreleased/42738-change-commit-user-mentions-commit-id-column-type.yml
...738-change-commit-user-mentions-commit-id-column-type.yml
+5
-0
db/migrate/20191212140117_change_commit_user_mentions_commit_id_column_type.rb
...0117_change_commit_user_mentions_commit_id_column_type.rb
+36
-0
db/post_migrate/20191212162434_change_commit_user_mentions_commit_id_column_type_cleanup.rb
...nge_commit_user_mentions_commit_id_column_type_cleanup.rb
+25
-0
db/schema.rb
db/schema.rb
+2
-2
No files found.
changelogs/unreleased/42738-change-commit-user-mentions-commit-id-column-type.yml
0 → 100644
View file @
e96624b0
---
title
:
Change commit_id type on commit_user_mentions table
merge_request
:
21651
author
:
type
:
fixed
db/migrate/20191212140117_change_commit_user_mentions_commit_id_column_type.rb
0 → 100644
View file @
e96624b0
# frozen_string_literal: true
class
ChangeCommitUserMentionsCommitIdColumnType
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
OLD_INDEX
=
'commit_user_mentions_on_commit_id_and_note_id_index'
OLD_TMP_INDEX
=
'temp_commit_id_and_note_id_index'
NEW_TMP_INDEX
=
'temp_commit_id_for_type_change_and_note_id_index'
NEW_INDEX
=
'commit_id_and_note_id_index'
def
up
# the initial index name is too long and fails during migration. Renaming the index first.
add_concurrent_index
:commit_user_mentions
,
[
:commit_id
,
:note_id
],
name:
OLD_TMP_INDEX
remove_concurrent_index_by_name
:commit_user_mentions
,
OLD_INDEX
change_column_type_concurrently
:commit_user_mentions
,
:commit_id
,
:string
# change_column_type_concurrently creates a new index for new column `commit_id_for_type` based on existing
# `temp_commit_id_and_note_id_index` naming it `temp_commit_id_for_type_change_and_note_id_index`, yet keeping
# `temp_commit_id_and_note_id_index` for `commit_id`, that will be cleaned
# by `cleanup_concurrent_column_type_change :commit_user_mentions, :commit_id` in a later migration.
#
# So we'll rename `temp_commit_id_for_type_change_and_note_id_index` to initialy intended name: `commit_id_and_note_id_index`.
add_concurrent_index
:commit_user_mentions
,
[
:commit_id_for_type_change
,
:note_id
],
name:
NEW_INDEX
remove_concurrent_index_by_name
:commit_user_mentions
,
NEW_TMP_INDEX
end
def
down
cleanup_concurrent_column_type_change
:commit_user_mentions
,
:commit_id
end
end
db/post_migrate/20191212162434_change_commit_user_mentions_commit_id_column_type_cleanup.rb
0 → 100644
View file @
e96624b0
# frozen_string_literal: true
class
ChangeCommitUserMentionsCommitIdColumnTypeCleanup
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
NEW_INDEX
=
'commit_id_for_type_change_and_note_id_index'
OLD_INDEX
=
'commit_user_mentions_on_commit_id_and_note_id_index'
def
up
cleanup_concurrent_column_type_change
:commit_user_mentions
,
:commit_id
end
def
down
change_column_type_concurrently
:commit_user_mentions
,
:commit_id
,
:binary
# change_column_type_concurrently creates a new index based on existing commit_id_and_note_id_index` naming it
# `commit_id_for_type_change_and_note_id_index` so we'll rename it back to its original name.
add_concurrent_index
:commit_user_mentions
,
[
:commit_id_for_type_change
,
:note_id
],
name:
OLD_INDEX
remove_concurrent_index_by_name
:commit_user_mentions
,
NEW_INDEX
end
end
db/schema.rb
View file @
e96624b0
...
...
@@ -1217,11 +1217,11 @@ ActiveRecord::Schema.define(version: 2019_12_14_175727) do
create_table
"commit_user_mentions"
,
force: :cascade
do
|
t
|
t
.
integer
"note_id"
,
null:
false
t
.
binary
"commit_id"
,
null:
false
t
.
integer
"mentioned_users_ids"
,
array:
true
t
.
integer
"mentioned_projects_ids"
,
array:
true
t
.
integer
"mentioned_groups_ids"
,
array:
true
t
.
index
[
"commit_id"
,
"note_id"
],
name:
"commit_user_mentions_on_commit_id_and_note_id_index"
t
.
string
"commit_id"
,
null:
false
t
.
index
[
"commit_id"
,
"note_id"
],
name:
"commit_id_and_note_id_index"
t
.
index
[
"note_id"
],
name:
"index_commit_user_mentions_on_note_id"
,
unique:
true
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