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
4efa059e
Commit
4efa059e
authored
Oct 13, 2021
by
Mikołaj Wawrzyniak
Committed by
Tiger Watson
Oct 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix invalid index on ci_builds table
parent
1537b5a4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
1 deletion
+59
-1
db/post_migrate/20211005083015_recreate_index_security_ci_builds_on_name_and_id_parser_features.rb
...ndex_security_ci_builds_on_name_and_id_parser_features.rb
+29
-0
db/schema_migrations/20211005083015
db/schema_migrations/20211005083015
+1
-0
db/structure.sql
db/structure.sql
+1
-1
spec/migrations/recreate_index_security_ci_builds_on_name_and_id_parser_features_spec.rb
...security_ci_builds_on_name_and_id_parser_features_spec.rb
+28
-0
No files found.
db/post_migrate/20211005083015_recreate_index_security_ci_builds_on_name_and_id_parser_features.rb
0 → 100644
View file @
4efa059e
# frozen_string_literal: true
class
RecreateIndexSecurityCiBuildsOnNameAndIdParserFeatures
<
Gitlab
::
Database
::
Migration
[
1.0
]
TABLE
=
"ci_builds"
OLD_INDEX_NAME
=
"index_security_ci_builds_on_name_and_id_parser_features"
NEW_INDEX_NAME
=
"index_security_ci_builds_on_name_and_id_parser_features_broken"
COLUMNS
=
%i[name id]
CONSTRAINTS
=
"(name::text = ANY (ARRAY['container_scanning'::character varying::text,
'dast'::character varying::text,
'dependency_scanning'::character varying::text,
'license_management'::character varying::text,
'sast'::character varying::text,
'secret_detection'::character varying::text,
'coverage_fuzzing'::character varying::text,
'license_scanning'::character varying::text])
) AND type::text = 'Ci::Build'::text"
enable_lock_retries!
def
up
rename_index
(
TABLE
,
OLD_INDEX_NAME
,
NEW_INDEX_NAME
)
prepare_async_index
TABLE
,
COLUMNS
,
name:
OLD_INDEX_NAME
,
where:
CONSTRAINTS
end
def
down
unprepare_async_index
TABLE
,
COLUMNS
,
name:
OLD_INDEX_NAME
rename_index
(
TABLE
,
NEW_INDEX_NAME
,
OLD_INDEX_NAME
)
end
end
db/schema_migrations/20211005083015
0 → 100644
View file @
4efa059e
37016ec5e5ab1bd8d2bd8020f98277b3ad9f450b833ce3ebde70aebce5130a26
\ No newline at end of file
db/structure.sql
View file @
4efa059e
...
...
@@ -26519,7 +26519,7 @@ CREATE UNIQUE INDEX index_scim_oauth_access_tokens_on_group_id_and_token_encrypt
CREATE INDEX index_secure_ci_builds_on_user_id_name_created_at ON ci_builds USING btree (user_id, name, created_at) WHERE (((type)::text = 'Ci::Build'::text) AND ((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('license_scanning'::character varying)::text, ('sast'::character varying)::text, ('coverage_fuzzing'::character varying)::text, ('apifuzzer_fuzz'::character varying)::text, ('apifuzzer_fuzz_dnd'::character varying)::text, ('secret_detection'::character varying)::text])));
CREATE INDEX index_security_ci_builds_on_name_and_id_parser_features ON ci_builds USING btree (name, id) WHERE (((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text, ('secret_detection'::character varying)::text, ('coverage_fuzzing'::character varying)::text, ('license_scanning'::character varying)::text])) AND ((type)::text = 'Ci::Build'::text));
CREATE INDEX index_security_ci_builds_on_name_and_id_parser_features
_broken
ON ci_builds USING btree (name, id) WHERE (((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text, ('secret_detection'::character varying)::text, ('coverage_fuzzing'::character varying)::text, ('license_scanning'::character varying)::text])) AND ((type)::text = 'Ci::Build'::text));
CREATE INDEX index_security_findings_on_confidence ON security_findings USING btree (confidence);
spec/migrations/recreate_index_security_ci_builds_on_name_and_id_parser_features_spec.rb
0 → 100644
View file @
4efa059e
# frozen_string_literal: true
require
'spec_helper'
require_migration!
RSpec
.
describe
RecreateIndexSecurityCiBuildsOnNameAndIdParserFeatures
,
:migration
do
let
(
:db
)
{
described_class
.
new
}
let
(
:pg_class
)
{
table
(
:pg_class
)
}
let
(
:pg_index
)
{
table
(
:pg_index
)
}
let
(
:async_indexes
)
{
table
(
:postgres_async_indexes
)
}
it
"recreates index"
do
reversible_migration
do
|
migration
|
migration
.
before
->
{
expect
(
async_indexes
.
where
(
name:
described_class
::
OLD_INDEX_NAME
).
exists?
).
to
be
false
expect
(
db
.
index_exists?
(
described_class
::
TABLE
,
described_class
::
COLUMNS
,
name:
described_class
::
OLD_INDEX_NAME
)).
to
be
true
expect
(
db
.
index_exists?
(
described_class
::
TABLE
,
described_class
::
COLUMNS
,
name:
described_class
::
NEW_INDEX_NAME
)).
to
be
false
}
migration
.
after
->
{
expect
(
async_indexes
.
where
(
name:
described_class
::
OLD_INDEX_NAME
).
exists?
).
to
be
true
expect
(
db
.
index_exists?
(
described_class
::
TABLE
,
described_class
::
COLUMNS
,
name:
described_class
::
OLD_INDEX_NAME
)).
to
be
false
expect
(
db
.
index_exists?
(
described_class
::
TABLE
,
described_class
::
COLUMNS
,
name:
described_class
::
NEW_INDEX_NAME
)).
to
be
true
}
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