summaryrefslogtreecommitdiff
path: root/db/post_migrate/20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb')
-rw-r--r--db/post_migrate/20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/db/post_migrate/20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb b/db/post_migrate/20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb
new file mode 100644
index 00000000000..38af5aae924
--- /dev/null
+++ b/db/post_migrate/20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb
@@ -0,0 +1,23 @@
+class BackfillRunnerTypeForCiRunnersPostMigrate < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ INSTANCE_RUNNER_TYPE = 1
+ PROJECT_RUNNER_TYPE = 3
+
+ disable_ddl_transaction!
+
+ def up
+ update_column_in_batches(:ci_runners, :runner_type, INSTANCE_RUNNER_TYPE) do |table, query|
+ query.where(table[:is_shared].eq(true)).where(table[:runner_type].eq(nil))
+ end
+
+ update_column_in_batches(:ci_runners, :runner_type, PROJECT_RUNNER_TYPE) do |table, query|
+ query.where(table[:is_shared].eq(false)).where(table[:runner_type].eq(nil))
+ end
+ end
+
+ def down
+ end
+end