Skip to content
Snippets Groups Projects
Unverified Commit f09dcbd9 authored by Kamil Trzcińśki's avatar Kamil Trzcińśki
Browse files

Make retried to be nullable

parent f2a4420d
No related branches found
No related tags found
2 merge requests!12073Add RC2 changes to 9-3-stable,!11115Retried in database
Pipeline #
Loading
@@ -31,7 +31,7 @@ class CommitStatus < ActiveRecord::Base
Loading
@@ -31,7 +31,7 @@ class CommitStatus < ActiveRecord::Base
false, all_state_names - [:failed, :canceled, :manual]) false, all_state_names - [:failed, :canceled, :manual])
end end
   
scope :latest, -> { where(retried: false) } scope :latest, -> { where(retried: [false, nil]) }
scope :retried, -> { where(retried: true) } scope :retried, -> { where(retried: true) }
scope :ordered, -> { order(:name) } scope :ordered, -> { order(:name) }
scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) } scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) }
Loading
Loading
Loading
@@ -22,7 +22,7 @@ module HasStatus
Loading
@@ -22,7 +22,7 @@ module HasStatus
skipped = scope.skipped.select('count(*)').to_sql skipped = scope.skipped.select('count(*)').to_sql
canceled = scope.canceled.select('count(*)').to_sql canceled = scope.canceled.select('count(*)').to_sql
   
"(CASE "(CASE
WHEN (#{builds})=(#{skipped}) THEN 'skipped' WHEN (#{builds})=(#{skipped}) THEN 'skipped'
WHEN (#{builds})=(#{success}) THEN 'success' WHEN (#{builds})=(#{success}) THEN 'success'
WHEN (#{builds})=(#{created}) THEN 'created' WHEN (#{builds})=(#{created}) THEN 'created'
Loading
Loading
Loading
@@ -30,8 +30,8 @@ module Ci
Loading
@@ -30,8 +30,8 @@ module Ci
   
Ci::Build.transaction do Ci::Build.transaction do
# mark all other builds of that name as retried # mark all other builds of that name as retried
build.pipeline.builds.where(name: build.name) build.pipeline.builds.latest
.where.not(retried: true) .where(name: build.name)
.update_all(retried: true) .update_all(retried: true)
   
project.builds.create!(Hash[attributes]) project.builds.create!(Hash[attributes])
Loading
Loading
Loading
@@ -3,13 +3,7 @@ class AddRetriedToCiBuild < ActiveRecord::Migration
Loading
@@ -3,13 +3,7 @@ class AddRetriedToCiBuild < ActiveRecord::Migration
   
DOWNTIME = false DOWNTIME = false
   
disable_ddl_transaction! def change
add_column(:ci_builds, :retried, :boolean)
def up
add_column_with_default(:ci_builds, :retried, :boolean, default: false)
end
def down
remove_column(:ci_builds, :retried)
end end
end end
Loading
@@ -20,7 +20,7 @@ class UpateRetriedForCiBuild < ActiveRecord::Migration
Loading
@@ -20,7 +20,7 @@ class UpateRetriedForCiBuild < ActiveRecord::Migration
is_retried = Arel.sql("((#{latest_id}) != ci_builds.id)") is_retried = Arel.sql("((#{latest_id}) != ci_builds.id)")
   
update_column_in_batches(:ci_builds, :retried, is_retried) do |table, query| 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
end end
   
Loading
Loading
Loading
@@ -232,7 +232,7 @@ ActiveRecord::Schema.define(version: 20170504102911) do
Loading
@@ -232,7 +232,7 @@ ActiveRecord::Schema.define(version: 20170504102911) do
t.integer "lock_version" t.integer "lock_version"
t.string "coverage_regex" t.string "coverage_regex"
t.integer "auto_canceled_by_id" t.integer "auto_canceled_by_id"
t.boolean "retried", default: false, null: false t.boolean "retried"
end 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 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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment