diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-04-30 16:00:28 +0300 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-04-30 16:01:35 +0300 |
commit | 0d30b00de807df550bec947751c098317c5bb79f (patch) | |
tree | fa9ed7849bcaf0ed07a96143ef72d9a1018c730d /db | |
parent | 3dbcc02db0c1fda22044a743158d4ba9e4eda637 (diff) |
Start persisting runner_type when creating runners
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20180430101916_add_runner_type_to_ci_runners.rb | 9 | ||||
-rw-r--r-- | db/post_migrate/20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb | 20 | ||||
-rw-r--r-- | db/schema.rb | 3 |
3 files changed, 31 insertions, 1 deletions
diff --git a/db/migrate/20180430101916_add_runner_type_to_ci_runners.rb b/db/migrate/20180430101916_add_runner_type_to_ci_runners.rb new file mode 100644 index 00000000000..8c8009f28fb --- /dev/null +++ b/db/migrate/20180430101916_add_runner_type_to_ci_runners.rb @@ -0,0 +1,9 @@ +class AddRunnerTypeToCiRunners < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_runners, :runner_type, :integer + end +end 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..8509222edc2 --- /dev/null +++ b/db/post_migrate/20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb @@ -0,0 +1,20 @@ +class BackfillRunnerTypeForCiRunnersPostMigrate < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + update_column_in_batches(:ci_runners, :runner_type, 1) 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, 3) do |table, query| + query.where(table[:is_shared].eq(false)).where(table[:runner_type].eq(nil)) + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index db1e41e00b3..4a541b3ac81 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180425131009) do +ActiveRecord::Schema.define(version: 20180430143705) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -479,6 +479,7 @@ ActiveRecord::Schema.define(version: 20180425131009) do t.integer "access_level", default: 0, null: false t.string "ip_address" t.integer "maximum_timeout" + t.integer "runner_type" end add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree |