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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
40a3b467
Commit
40a3b467
authored
Feb 26, 2018
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add the Ci::Build `*_store` column
parent
e43d7d2b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
21 deletions
+27
-21
app/models/ci/build.rb
app/models/ci/build.rb
+4
-0
db/migrate/20180222152310_port_object_storage_to_ce.rb
db/migrate/20180222152310_port_object_storage_to_ce.rb
+21
-21
db/schema.rb
db/schema.rb
+2
-0
No files found.
app/models/ci/build.rb
View file @
40a3b467
...
@@ -3,6 +3,7 @@ module Ci
...
@@ -3,6 +3,7 @@ module Ci
prepend
ArtifactMigratable
prepend
ArtifactMigratable
include
TokenAuthenticatable
include
TokenAuthenticatable
include
AfterCommitQueue
include
AfterCommitQueue
include
ObjectStorage
::
BackgroundMove
include
Presentable
include
Presentable
include
Importable
include
Importable
...
@@ -41,10 +42,13 @@ module Ci
...
@@ -41,10 +42,13 @@ module Ci
scope
:unstarted
,
->
()
{
where
(
runner_id:
nil
)
}
scope
:unstarted
,
->
()
{
where
(
runner_id:
nil
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
scope
:with_artifacts
,
->
()
do
scope
:with_artifacts
,
->
()
do
where
(
'(artifacts_file IS NOT NULL AND artifacts_file <> ?) OR EXISTS (?)'
,
where
(
'(artifacts_file IS NOT NULL AND artifacts_file <> ?) OR EXISTS (?)'
,
''
,
Ci
::
JobArtifact
.
select
(
1
).
where
(
'ci_builds.id = ci_job_artifacts.job_id'
))
''
,
Ci
::
JobArtifact
.
select
(
1
).
where
(
'ci_builds.id = ci_job_artifacts.job_id'
))
end
end
scope
:with_artifacts_stored_locally
,
->
{
with_artifacts
.
where
(
artifacts_file_store:
[
nil
,
LegacyArtifactUploader
::
Store
::
LOCAL
])
}
scope
:with_artifacts_not_expired
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at IS NULL OR artifacts_expire_at > ?'
,
Time
.
now
)
}
scope
:with_artifacts_not_expired
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at IS NULL OR artifacts_expire_at > ?'
,
Time
.
now
)
}
scope
:with_expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:with_expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:with_artifacts_stored_locally
,
->
()
{
with_artifacts
.
where
(
artifacts_file_store:
[
nil
,
LegacyArtifactUploader
::
Store
::
LOCAL
])
}
scope
:with_artifacts_stored_locally
,
->
()
{
with_artifacts
.
where
(
artifacts_file_store:
[
nil
,
LegacyArtifactUploader
::
Store
::
LOCAL
])
}
...
...
db/migrate/20180222152310_port_object_storage_to_ce.rb
View file @
40a3b467
...
@@ -7,31 +7,31 @@ class PortObjectStorageToCe < ActiveRecord::Migration
...
@@ -7,31 +7,31 @@ class PortObjectStorageToCe < ActiveRecord::Migration
# Set this constant to true if this migration requires downtime.
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
DOWNTIME
=
false
def
up
def
add_column_idempotent
(
table
,
column
,
*
defs
)
unless
column_exists?
(
:ci_job_artifacts
,
:file_store
)
return
if
column_exists?
(
table
,
column
)
add_column
(
:ci_job_artifacts
,
:file_store
,
:integer
)
end
unless
column_exists?
(
:lfs_objects
,
:file_store
)
add_column
(
table
,
column
,
*
defs
)
add_column
(
:lfs_objects
,
:file_store
,
:integer
)
end
end
unless
column_exists?
(
:uploads
,
:store
)
def
remove_column_idempotent
(
table
,
column
)
add_column
(
:uploads
,
:store
,
:integer
)
return
unless
column_exists?
(
table
,
column
)
end
end
def
down
remove_column
(
table
,
column
)
if
column_exists?
(
:ci_job_artifacts
,
:file_store
)
remove_column
(
:ci_job_artifacts
,
:file_store
)
end
end
if
column_exists?
(
:lfs_objects
,
:file_store
)
def
up
remove_column
(
:lfs_objects
,
:file_store
)
add_column_idempotent
(
:ci_job_artifacts
,
:file_store
,
:integer
)
add_column_idempotent
(
:ci_builds
,
:artifacts_file_store
,
:integer
)
add_column_idempotent
(
:ci_builds
,
:artifacts_metadata_store
,
:integer
)
add_column_idempotent
(
:lfs_objects
,
:file_store
,
:integer
)
add_column_idempotent
(
:uploads
,
:store
,
:integer
)
end
end
if
column_exists?
(
:uploads
,
:store
)
def
down
remove_column
(
:uploads
,
:store
)
remove_column_idempotent
(
:ci_job_artifacts
,
:file_store
)
end
remove_column_idempotent
(
:ci_builds
,
:artifacts_file_store
)
remove_column_idempotent
(
:ci_builds
,
:artifacts_metadata_store
)
remove_column_idempotent
(
:lfs_objects
,
:file_store
)
remove_column_idempotent
(
:uploads
,
:store
)
end
end
end
end
db/schema.rb
View file @
40a3b467
...
@@ -294,6 +294,8 @@ ActiveRecord::Schema.define(version: 20180222152310) do
...
@@ -294,6 +294,8 @@ ActiveRecord::Schema.define(version: 20180222152310) do
t
.
integer
"artifacts_metadata_store"
,
default:
1
,
null:
false
t
.
integer
"artifacts_metadata_store"
,
default:
1
,
null:
false
t
.
boolean
"protected"
t
.
boolean
"protected"
t
.
integer
"failure_reason"
t
.
integer
"failure_reason"
t
.
integer
"artifacts_file_store"
t
.
integer
"artifacts_metadata_store"
end
end
add_index
"ci_builds"
,
[
"artifacts_expire_at"
],
name:
"index_ci_builds_on_artifacts_expire_at"
,
where:
"(artifacts_file <> ''::text)"
,
using: :btree
add_index
"ci_builds"
,
[
"artifacts_expire_at"
],
name:
"index_ci_builds_on_artifacts_expire_at"
,
where:
"(artifacts_file <> ''::text)"
,
using: :btree
...
...
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