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
f020d8e8
Commit
f020d8e8
authored
Sep 28, 2021
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unexpected FK prior to swapping columns
See
https://gitlab.com/gitlab-org/gitlab/-/issues/341822
parent
5eaaf70a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
db/post_migrate/20210907211557_finalize_ci_builds_bigint_conversion.rb
...te/20210907211557_finalize_ci_builds_bigint_conversion.rb
+5
-0
spec/migrations/20210907211557_finalize_ci_builds_bigint_conversion_spec.rb
...210907211557_finalize_ci_builds_bigint_conversion_spec.rb
+18
-0
spec/support/database/cross-join-allowlist.yml
spec/support/database/cross-join-allowlist.yml
+1
-0
No files found.
db/post_migrate/20210907211557_finalize_ci_builds_bigint_conversion.rb
View file @
f020d8e8
...
...
@@ -103,6 +103,11 @@ class FinalizeCiBuildsBigintConversion < Gitlab::Database::Migration[1.0]
remove_foreign_key
(
:ci_resources
,
TABLE_NAME
,
column: :build_id
,
name:
'fk_rails_e169a8e3d5'
)
end
# Remove this unexpected FK if it exists - https://gitlab.com/gitlab-org/gitlab/-/issues/341822
if
foreign_key_exists?
(
:ci_sources_pipelines
,
TABLE_NAME
,
column: :source_job_id
,
name:
'fk_3f0c88d7dc'
)
remove_foreign_key
(
:ci_sources_pipelines
,
TABLE_NAME
,
column: :source_job_id
,
name:
'fk_3f0c88d7dc'
)
end
swap_columns
end
...
...
spec/migrations/20210907211557_finalize_ci_builds_bigint_conversion_spec.rb
0 → 100644
View file @
f020d8e8
# frozen_string_literal: true
require
'spec_helper'
require_migration!
(
'finalize_ci_builds_bigint_conversion'
)
RSpec
.
describe
FinalizeCiBuildsBigintConversion
,
:migration
,
schema:
20210907182359
do
context
'with an unexpected FK fk_3f0c88d7dc'
do
it
'removes the FK and migrates successfully'
do
# Add the unexpected FK
subject
.
add_foreign_key
(
:ci_sources_pipelines
,
:ci_builds
,
column: :source_job_id
,
name:
'fk_3f0c88d7dc'
)
expect
{
migrate!
}.
to
change
{
subject
.
foreign_key_exists?
(
:ci_sources_pipelines
,
:ci_builds
,
column: :source_job_id
,
name:
'fk_3f0c88d7dc'
)
}.
from
(
true
).
to
(
false
)
# Additional check: The actually expected FK should still exist
expect
(
subject
.
foreign_key_exists?
(
:ci_sources_pipelines
,
:ci_builds
,
column: :source_job_id
,
name:
'fk_be5624bf37'
)).
to
be_truthy
end
end
end
spec/support/database/cross-join-allowlist.yml
View file @
f020d8e8
...
...
@@ -63,6 +63,7 @@
-
"
./spec/lib/api/entities/package_spec.rb"
-
"
./spec/lib/gitlab/background_migration/migrate_legacy_artifacts_spec.rb"
-
"
./spec/mailers/emails/pipelines_spec.rb"
-
"
./spec/migrations/20210907211557_finalize_ci_builds_bigint_conversion_spec.rb"
-
"
./spec/migrations/cleanup_legacy_artifact_migration_spec.rb"
-
"
./spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb"
-
"
./spec/migrations/re_schedule_latest_pipeline_id_population_with_all_security_related_artifact_types_spec.rb"
...
...
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