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
Jérome Perrin
gitlab-ce
Commits
d34e8781
Commit
d34e8781
authored
Jun 23, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old project_id index and make sure mysql work
parent
5eb4a472
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
5 deletions
+34
-5
db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb
...e/20170622135728_add_unique_constraint_to_ci_variables.rb
+14
-4
db/migrate/20170623080805_remove_ci_variables_project_id_index.rb
...te/20170623080805_remove_ci_variables_project_id_index.rb
+19
-0
db/schema.rb
db/schema.rb
+1
-1
No files found.
db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb
View file @
d34e8781
...
@@ -6,18 +6,28 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration
...
@@ -6,18 +6,28 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration
disable_ddl_transaction!
disable_ddl_transaction!
def
up
def
up
unless
index_exists?
(
:ci_variables
,
columns
)
unless
this_index_exists?
add_concurrent_index
(
:ci_variables
,
columns
,
unique:
true
)
add_concurrent_index
(
:ci_variables
,
columns
,
name:
index_name
,
unique:
true
)
end
end
end
end
def
down
def
down
if
index_exists?
(
:ci_variables
,
columns
)
&&
Gitlab
::
Database
.
postgresql?
if
this_index_exists?
&&
Gitlab
::
Database
.
postgresql?
remove_concurrent_index
(
:ci_variables
,
columns
)
remove_concurrent_index
(
:ci_variables
,
columns
,
name:
index_name
)
end
end
end
end
private
def
this_index_exists?
index_exists?
(
:ci_variables
,
name:
index_name
)
end
def
columns
def
columns
@columns
||=
[
:project_id
,
:key
,
:environment_scope
]
@columns
||=
[
:project_id
,
:key
,
:environment_scope
]
end
end
def
index_name
'index_ci_variables_on_project_id_and_key_and_environment_scope'
end
end
end
db/migrate/20170623080805_remove_ci_variables_project_id_index.rb
0 → 100644
View file @
d34e8781
class
RemoveCiVariablesProjectIdIndex
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
if
index_exists?
(
:ci_variables
,
:project_id
)
remove_concurrent_index
(
:ci_variables
,
:project_id
)
end
end
def
down
unless
index_exists?
(
:ci_variables
,
:project_id
)
add_concurrent_index
(
:ci_variables
,
:project_id
)
end
end
end
db/schema.rb
View file @
d34e8781
...
@@ -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:
2017062
2135728
)
do
ActiveRecord
::
Schema
.
define
(
version:
2017062
3080805
)
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"
...
...
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