diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-04-16 14:14:39 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-05-07 23:43:53 +0300 |
commit | f2a4420d66216e3a9172f4ab45c6b4fa96578117 (patch) | |
tree | 6b7c8845c085f804a02e2ead9109910fd30e667e /db/post_migrate | |
parent | 6ad3814e1b31bfacfae7a2aabb4e4607b12ca66f (diff) |
Store retried in database for CI builds
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20170503004427_upate_retried_for_ci_build.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb b/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb new file mode 100644 index 00000000000..e12180930a7 --- /dev/null +++ b/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb @@ -0,0 +1,29 @@ +class UpateRetriedForCiBuild < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + disable_statement_timeout + + latest_id = <<-SQL.strip_heredoc + SELECT MAX(ci_builds2.id) + FROM ci_builds ci_builds2 + WHERE ci_builds.commit_id=ci_builds2.commit_id + AND ci_builds.name=ci_builds2.name + SQL + + # This is slow update as it does single-row query + # This is designed to be run as idle, or a post deployment 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)) + end + end + + def down + end +end |