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
ddcbaece
Commit
ddcbaece
authored
Feb 03, 2020
by
Mikolaj Wawrzyniak
Committed by
Stan Hu
Feb 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove temporary index at services on project_id
parent
2edc16b9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
1 deletion
+67
-1
changelogs/unreleased/196858-cleanup-temporary-index-at-services-table-on-project_id.yml
...eanup-temporary-index-at-services-table-on-project_id.yml
+5
-0
db/post_migrate/20200203104214_services_remove_temporary_index_on_project_id.rb
...03104214_services_remove_temporary_index_on_project_id.rb
+22
-0
db/schema.rb
db/schema.rb
+0
-1
spec/migrations/services_remove_temporary_index_on_project_id_spec.rb
...ons/services_remove_temporary_index_on_project_id_spec.rb
+40
-0
No files found.
changelogs/unreleased/196858-cleanup-temporary-index-at-services-table-on-project_id.yml
0 → 100644
View file @
ddcbaece
---
title
:
Remove temporary index at services on project_id
merge_request
:
24263
author
:
type
:
removed
db/post_migrate/20200203104214_services_remove_temporary_index_on_project_id.rb
0 → 100644
View file @
ddcbaece
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
ServicesRemoveTemporaryIndexOnProjectId
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
INDEX_NAME
=
'tmp_index_on_project_id_partial_with_prometheus_services'
PARTIAL_FILTER
=
"type = 'PrometheusService'"
disable_ddl_transaction!
def
up
remove_concurrent_index
:services
,
:project_id
,
where:
PARTIAL_FILTER
,
name:
INDEX_NAME
end
def
down
add_concurrent_index
:services
,
:project_id
,
where:
PARTIAL_FILTER
,
name:
INDEX_NAME
end
end
db/schema.rb
View file @
ddcbaece
...
...
@@ -3846,7 +3846,6 @@ ActiveRecord::Schema.define(version: 2020_02_06_111847) do
t
.
boolean
"instance"
,
default:
false
t
.
index
[
"instance"
],
name:
"index_services_on_instance"
t
.
index
[
"project_id"
],
name:
"index_services_on_project_id"
t
.
index
[
"project_id"
],
name:
"tmp_index_on_project_id_partial_with_prometheus_services"
,
where:
"((type)::text = 'PrometheusService'::text)"
t
.
index
[
"type"
],
name:
"index_services_on_type"
end
...
...
spec/migrations/services_remove_temporary_index_on_project_id_spec.rb
0 → 100644
View file @
ddcbaece
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20200203104214_services_remove_temporary_index_on_project_id.rb'
)
describe
ServicesRemoveTemporaryIndexOnProjectId
,
:migration
do
let
(
:migration_instance
)
{
described_class
.
new
}
it
'adds and removes temporary partial index in up and down methods'
do
reversible_migration
do
|
migration
|
migration
.
before
->
{
expect
(
migration_instance
.
index_exists?
(
:services
,
:project_id
,
name:
described_class
::
INDEX_NAME
)).
to
be
true
}
migration
.
after
->
{
expect
(
migration_instance
.
index_exists?
(
:services
,
:project_id
,
name:
described_class
::
INDEX_NAME
)).
to
be
false
}
end
end
describe
'#up'
do
context
'index does not exist'
do
it
'skips removal action'
do
migrate!
expect
{
migrate!
}.
not_to
change
{
migration_instance
.
index_exists?
(
:services
,
:project_id
,
name:
described_class
::
INDEX_NAME
)
}
end
end
end
describe
'#down'
do
context
'index already exists'
do
it
'skips creation of duplicated temporary partial index on project_id'
do
schema_migrate_down!
expect
{
schema_migrate_down!
}.
not_to
change
{
migration_instance
.
index_exists?
(
:services
,
:project_id
,
name:
described_class
::
INDEX_NAME
)
}
end
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