Commit 40a3b467 authored by Micaël Bergeron's avatar Micaël Bergeron

add the Ci::Build `*_store` column

parent e43d7d2b
......@@ -3,6 +3,7 @@ module Ci
prepend ArtifactMigratable
include TokenAuthenticatable
include AfterCommitQueue
include ObjectStorage::BackgroundMove
include Presentable
include Importable
......@@ -41,10 +42,13 @@ module Ci
scope :unstarted, ->() { where(runner_id: nil) }
scope :ignore_failures, ->() { where(allow_failure: false) }
scope :with_artifacts, ->() do
where('(artifacts_file IS NOT NULL AND artifacts_file <> ?) OR EXISTS (?)',
'', Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id'))
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_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]) }
......
......@@ -7,31 +7,31 @@ class PortObjectStorageToCe < ActiveRecord::Migration
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
unless column_exists?(:ci_job_artifacts, :file_store)
add_column(:ci_job_artifacts, :file_store, :integer)
end
unless column_exists?(:lfs_objects, :file_store)
add_column(:lfs_objects, :file_store, :integer)
end
def add_column_idempotent(table, column, *defs)
return if column_exists?(table, column)
unless column_exists?(:uploads, :store)
add_column(:uploads, :store, :integer)
end
add_column(table, column, *defs)
end
def down
if column_exists?(:ci_job_artifacts, :file_store)
remove_column(:ci_job_artifacts, :file_store)
end
def remove_column_idempotent(table, column)
return unless column_exists?(table, column)
remove_column(table, column)
end
if column_exists?(:lfs_objects, :file_store)
remove_column(:lfs_objects, :file_store)
end
def up
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
if column_exists?(:uploads, :store)
remove_column(:uploads, :store)
end
def down
remove_column_idempotent(:ci_job_artifacts, :file_store)
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
......@@ -294,6 +294,8 @@ ActiveRecord::Schema.define(version: 20180222152310) do
t.integer "artifacts_metadata_store", default: 1, null: false
t.boolean "protected"
t.integer "failure_reason"
t.integer "artifacts_file_store"
t.integer "artifacts_metadata_store"
end
add_index "ci_builds", ["artifacts_expire_at"], name: "index_ci_builds_on_artifacts_expire_at", where: "(artifacts_file <> ''::text)", using: :btree
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment