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
4f727ada
Commit
4f727ada
authored
Feb 23, 2022
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix migration by handling empty result sets
parent
8acc5d32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
6 deletions
+8
-6
db/post_migrate/20220204194347_encrypt_integration_properties.rb
..._migrate/20220204194347_encrypt_integration_properties.rb
+1
-1
lib/gitlab/background_migration/encrypt_integration_properties.rb
...ab/background_migration/encrypt_integration_properties.rb
+2
-0
spec/migrations/20220204194347_encrypt_integration_properties_spec.rb
...ons/20220204194347_encrypt_integration_properties_spec.rb
+5
-5
No files found.
db/post_migrate/20220204194347_encrypt_integration_properties.rb
View file @
4f727ada
...
...
@@ -8,7 +8,7 @@ class EncryptIntegrationProperties < Gitlab::Database::Migration[1.0]
def
up
queue_background_migration_jobs_by_range_at_intervals
(
define_batchable_model
(
'integrations'
),
define_batchable_model
(
'integrations'
)
.
all
,
MIGRATION
,
INTERVAL
,
track_jobs:
true
,
...
...
lib/gitlab/background_migration/encrypt_integration_properties.rb
View file @
4f727ada
...
...
@@ -64,6 +64,8 @@ module Gitlab
"(
#{
record
.
id
}
,
#{
bytea
(
encrypted_properties
)
}
,
#{
bytea
(
encrypted_properties_iv
)
}
)"
end
return
if
values
.
empty?
Integration
.
connection
.
execute
(
<<~
SQL
.
squish
)
WITH cte(cte_id, cte_encrypted_properties, cte_encrypted_properties_iv)
AS
#{
::
Gitlab
::
Database
::
AsWithMaterialized
.
materialized_if_supported
}
(
...
...
spec/migrations/20220204194347_encrypt_integration_properties_spec.rb
View file @
4f727ada
...
...
@@ -18,18 +18,18 @@ RSpec.describe EncryptIntegrationProperties, :migration, schema: 20220204193000
record1
=
integrations
.
create!
(
properties:
some_props
)
record2
=
integrations
.
create!
(
properties:
some_props
)
record3
=
integrations
.
create!
(
properties:
some_props
)
# no update required
integrations
.
create!
(
properties:
nil
)
record4
=
integrations
.
create!
(
properties:
nil
)
record5
=
integrations
.
create!
(
properties:
nil
)
Sidekiq
::
Testing
.
fake!
do
freeze_time
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
record1
.
id
,
record2
.
id
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
record3
.
id
,
record3
.
id
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
record3
.
id
,
record4
.
id
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
record5
.
id
,
record5
.
id
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
(
2
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
(
3
)
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