summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-05-09 13:14:45 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2017-05-09 20:09:41 +0200
commitf09dcbd9bd2590bb66ee49b65637525a3c71a307 (patch)
tree8cdcbb6667697c559b59c4548c0857da364b8128
parentf2a4420d66216e3a9172f4ab45c6b4fa96578117 (diff)
downloadgitlab-ce-f09dcbd9bd2590bb66ee49b65637525a3c71a307.tar.gz
Make retried to be nullable
-rw-r--r--app/models/commit_status.rb2
-rw-r--r--app/models/concerns/has_status.rb2
-rw-r--r--app/services/ci/retry_build_service.rb4
-rw-r--r--db/migrate/20170503004426_add_retried_to_ci_build.rb10
-rw-r--r--db/post_migrate/20170503004427_upate_retried_for_ci_build.rb2
-rw-r--r--db/schema.rb2
6 files changed, 8 insertions, 14 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 528bf4d87ac..7855c16ee5b 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -31,7 +31,7 @@ class CommitStatus < ActiveRecord::Base
false, all_state_names - [:failed, :canceled, :manual])
end
- scope :latest, -> { where(retried: false) }
+ scope :latest, -> { where(retried: [false, nil]) }
scope :retried, -> { where(retried: true) }
scope :ordered, -> { order(:name) }
scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) }
diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb
index dff7b6e3523..3e4f8e6bff8 100644
--- a/app/models/concerns/has_status.rb
+++ b/app/models/concerns/has_status.rb
@@ -22,7 +22,7 @@ module HasStatus
skipped = scope.skipped.select('count(*)').to_sql
canceled = scope.canceled.select('count(*)').to_sql
- "(CASE
+ "(CASE
WHEN (#{builds})=(#{skipped}) THEN 'skipped'
WHEN (#{builds})=(#{success}) THEN 'success'
WHEN (#{builds})=(#{created}) THEN 'created'
diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb
index 9c532b585a1..f51e9fd1d54 100644
--- a/app/services/ci/retry_build_service.rb
+++ b/app/services/ci/retry_build_service.rb
@@ -30,8 +30,8 @@ module Ci
Ci::Build.transaction do
# mark all other builds of that name as retried
- build.pipeline.builds.where(name: build.name)
- .where.not(retried: true)
+ build.pipeline.builds.latest
+ .where(name: build.name)
.update_all(retried: true)
project.builds.create!(Hash[attributes])
diff --git a/db/migrate/20170503004426_add_retried_to_ci_build.rb b/db/migrate/20170503004426_add_retried_to_ci_build.rb
index 9f509f97f14..2851e3de473 100644
--- a/db/migrate/20170503004426_add_retried_to_ci_build.rb
+++ b/db/migrate/20170503004426_add_retried_to_ci_build.rb
@@ -3,13 +3,7 @@ class AddRetriedToCiBuild < ActiveRecord::Migration
DOWNTIME = false
- disable_ddl_transaction!
-
- def up
- add_column_with_default(:ci_builds, :retried, :boolean, default: false)
- end
-
- def down
- remove_column(:ci_builds, :retried)
+ def change
+ add_column(:ci_builds, :retried, :boolean)
end
end
diff --git a/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb b/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb
index e12180930a7..80215d662e4 100644
--- a/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb
+++ b/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb
@@ -20,7 +20,7 @@ class UpateRetriedForCiBuild < ActiveRecord::Migration
is_retried = Arel.sql("((#{latest_id}) != ci_builds.id)")
update_column_in_batches(:ci_builds, :retried, is_retried) do |table, query|
- query.where(table[:retried].eq(false))
+ query.where(table[:retried].eq(nil))
end
end
diff --git a/db/schema.rb b/db/schema.rb
index 8046e9b48a7..a54a57bd4da 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -232,7 +232,7 @@ ActiveRecord::Schema.define(version: 20170504102911) do
t.integer "lock_version"
t.string "coverage_regex"
t.integer "auto_canceled_by_id"
- t.boolean "retried", default: false, null: false
+ t.boolean "retried"
end
add_index "ci_builds", ["commit_id", "stage_idx", "created_at"], name: "index_ci_builds_on_commit_id_and_stage_idx_and_created_at", using: :btree