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
8498d108
Commit
8498d108
authored
Jun 10, 2021
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add protected pending build column and migrate data
Changelog: performance
parent
3c580c1a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
1 deletion
+68
-1
db/migrate/20210610102410_add_protected_attribute_to_pending_builds.rb
...210610102410_add_protected_attribute_to_pending_builds.rb
+7
-0
db/post_migrate/20210610102413_migrate_protected_attribute_to_pending_builds.rb
...10102413_migrate_protected_attribute_to_pending_builds.rb
+24
-0
db/schema_migrations/20210610102410
db/schema_migrations/20210610102410
+1
-0
db/schema_migrations/20210610102413
db/schema_migrations/20210610102413
+1
-0
db/structure.sql
db/structure.sql
+2
-1
spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb
...ons/migrate_protected_attribute_to_pending_builds_spec.rb
+33
-0
No files found.
db/migrate/20210610102410_add_protected_attribute_to_pending_builds.rb
0 → 100644
View file @
8498d108
# frozen_string_literal: true
class
AddProtectedAttributeToPendingBuilds
<
ActiveRecord
::
Migration
[
6.1
]
def
change
add_column
:ci_pending_builds
,
:protected
,
:boolean
,
null:
false
,
default:
false
end
end
db/post_migrate/20210610102413_migrate_protected_attribute_to_pending_builds.rb
0 → 100644
View file @
8498d108
# frozen_string_literal: true
class
MigrateProtectedAttributeToPendingBuilds
<
ActiveRecord
::
Migration
[
6.1
]
include
::
Gitlab
::
Database
::
DynamicModelHelpers
disable_ddl_transaction!
def
up
each_batch_range
(
'ci_pending_builds'
,
of:
1000
)
do
|
min
,
max
|
execute
<<~
SQL
UPDATE ci_pending_builds
SET protected = true
FROM ci_builds
WHERE ci_pending_builds.build_id = ci_builds.id
AND ci_builds.protected = true
AND ci_pending_builds.id BETWEEN
#{
min
}
AND
#{
max
}
SQL
end
end
def
down
# no op
end
end
db/schema_migrations/20210610102410
0 → 100644
View file @
8498d108
dab13c78f6f758c63be923277c0f31e4cce4e30f77a8dc2983a9bb1500a454f9
\ No newline at end of file
db/schema_migrations/20210610102413
0 → 100644
View file @
8498d108
ce21070d44a34081c6babd14e6a1b607bad5ed9047b18f4ef0beb64b5a2ce120
\ No newline at end of file
db/structure.sql
View file @
8498d108
...
@@ -10838,7 +10838,8 @@ CREATE TABLE ci_pending_builds (
...
@@ -10838,7 +10838,8 @@ CREATE TABLE ci_pending_builds (
id bigint NOT NULL,
id bigint NOT NULL,
build_id bigint NOT NULL,
build_id bigint NOT NULL,
project_id bigint NOT NULL,
project_id bigint NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL
created_at timestamp with time zone DEFAULT now() NOT NULL,
protected boolean DEFAULT false NOT NULL
);
);
CREATE SEQUENCE ci_pending_builds_id_seq
CREATE SEQUENCE ci_pending_builds_id_seq
spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb
0 → 100644
View file @
8498d108
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20210610102413_migrate_protected_attribute_to_pending_builds.rb'
)
RSpec
.
describe
MigrateProtectedAttributeToPendingBuilds
do
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:queue
)
{
table
(
:ci_pending_builds
)
}
let
(
:builds
)
{
table
(
:ci_builds
)
}
before
do
namespaces
.
create!
(
id:
123
,
name:
'sample'
,
path:
'sample'
)
projects
.
create!
(
id:
123
,
name:
'sample'
,
path:
'sample'
,
namespace_id:
123
)
builds
.
create!
(
id:
1
,
project_id:
123
,
status:
'pending'
,
protected:
false
,
type:
'Ci::Build'
)
builds
.
create!
(
id:
2
,
project_id:
123
,
status:
'pending'
,
protected:
true
,
type:
'Ci::Build'
)
builds
.
create!
(
id:
3
,
project_id:
123
,
status:
'pending'
,
protected:
false
,
type:
'Ci::Build'
)
builds
.
create!
(
id:
4
,
project_id:
123
,
status:
'pending'
,
protected:
true
,
type:
'Ci::Bridge'
)
builds
.
create!
(
id:
5
,
project_id:
123
,
status:
'success'
,
protected:
true
,
type:
'Ci::Build'
)
queue
.
create!
(
id:
1
,
project_id:
123
,
build_id:
1
)
queue
.
create!
(
id:
2
,
project_id:
123
,
build_id:
2
)
queue
.
create!
(
id:
3
,
project_id:
123
,
build_id:
3
)
end
it
'updates entries that should be protected'
do
migrate!
expect
(
queue
.
where
(
protected:
true
).
count
).
to
eq
1
expect
(
queue
.
find_by
(
protected:
true
).
id
).
to
eq
2
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