summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-08-16 23:13:43 +0900
committerShinya Maeda <shinya@gitlab.com>2017-09-03 23:49:10 +0900
commit0a7b3ae9f1a67645c798dfbfc60388c4c9cb5b95 (patch)
tree0512cc05401c6a1d7c572f14ea0e3ec3d4963c7d
parent23ac401b6e9883d2bd6beaef30e686d67ece791e (diff)
downloadgitlab-ce-0a7b3ae9f1a67645c798dfbfc60388c4c9cb5b95.tar.gz
Re-organize schema. Drop protected from runner. Add access_level to runner. Drop protected from pipeline. Add protected to ci_bilds.
-rw-r--r--app/models/ci/runner.rb5
-rw-r--r--db/migrate/20170731123938_add_protected_to_ci_runners.rb15
-rw-r--r--db/migrate/20170731132235_add_protected_to_ci_pipelines.rb15
-rw-r--r--db/migrate/20170816133938_add_access_level_to_ci_runners.rb16
-rw-r--r--db/migrate/20170816133939_add_index_on_ci_runners_access_level.rb15
-rw-r--r--db/migrate/20170816133940_add_protected_to_ci_builds.rb7
-rw-r--r--db/schema.rb5
7 files changed, 46 insertions, 32 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index 05b45be5e91..fd96592e6db 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -40,6 +40,11 @@ module Ci
after_destroy :cleanup_runner_queue
+ enum access_level: {
+ protection_none: 0,
+ protection_full: 1
+ }
+
# Searches for runners matching the given query.
#
# This method uses ILIKE on PostgreSQL and LIKE on MySQL.
diff --git a/db/migrate/20170731123938_add_protected_to_ci_runners.rb b/db/migrate/20170731123938_add_protected_to_ci_runners.rb
deleted file mode 100644
index 3782e047eee..00000000000
--- a/db/migrate/20170731123938_add_protected_to_ci_runners.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-class AddProtectedToCiRunners < ActiveRecord::Migration
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- def up
- add_column_with_default(:ci_runners, :protected, :boolean, default: false)
- end
-
- def down
- remove_column(:ci_runners, :protected)
- end
-end
diff --git a/db/migrate/20170731132235_add_protected_to_ci_pipelines.rb b/db/migrate/20170731132235_add_protected_to_ci_pipelines.rb
deleted file mode 100644
index d2d2b6733f6..00000000000
--- a/db/migrate/20170731132235_add_protected_to_ci_pipelines.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-class AddProtectedToCiPipelines < ActiveRecord::Migration
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- def up
- add_column(:ci_pipelines, :protected, :boolean)
- end
-
- def down
- remove_column(:ci_pipelines, :protected)
- end
-end
diff --git a/db/migrate/20170816133938_add_access_level_to_ci_runners.rb b/db/migrate/20170816133938_add_access_level_to_ci_runners.rb
new file mode 100644
index 00000000000..8cda0c3a717
--- /dev/null
+++ b/db/migrate/20170816133938_add_access_level_to_ci_runners.rb
@@ -0,0 +1,16 @@
+class AddAccessLevelToCiRunners < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # Ci::Runner.protection_none: 0
+ add_column_with_default(:ci_runners, :access_level, :integer, default: 0)
+ end
+
+ def down
+ remove_column(:ci_runners, :access_level)
+ end
+end
diff --git a/db/migrate/20170816133939_add_index_on_ci_runners_access_level.rb b/db/migrate/20170816133939_add_index_on_ci_runners_access_level.rb
new file mode 100644
index 00000000000..4239bf6f9cb
--- /dev/null
+++ b/db/migrate/20170816133939_add_index_on_ci_runners_access_level.rb
@@ -0,0 +1,15 @@
+class AddIndexOnCiRunnersAccessLevel < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_runners, :access_level
+ end
+
+ def down
+ remove_concurrent_index :ci_runners, :access_level if index_exists?(:ci_runners, :access_level)
+ end
+end
diff --git a/db/migrate/20170816133940_add_protected_to_ci_builds.rb b/db/migrate/20170816133940_add_protected_to_ci_builds.rb
new file mode 100644
index 00000000000..c73a4387d29
--- /dev/null
+++ b/db/migrate/20170816133940_add_protected_to_ci_builds.rb
@@ -0,0 +1,7 @@
+class AddProtectedToCiBuilds < ActiveRecord::Migration
+ DOWNTIME = false
+
+ def change
+ add_column :ci_builds, :protected, :boolean
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 85cb4e99b10..c933b47ab01 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -246,6 +246,7 @@ ActiveRecord::Schema.define(version: 20170824162758) do
t.integer "auto_canceled_by_id"
t.boolean "retried"
t.integer "stage_id"
+ t.boolean "protected"
end
add_index "ci_builds", ["auto_canceled_by_id"], name: "index_ci_builds_on_auto_canceled_by_id", using: :btree
@@ -336,7 +337,6 @@ ActiveRecord::Schema.define(version: 20170824162758) do
t.integer "auto_canceled_by_id"
t.integer "pipeline_schedule_id"
t.integer "source"
- t.boolean "protected"
end
add_index "ci_pipelines", ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree
@@ -372,9 +372,10 @@ ActiveRecord::Schema.define(version: 20170824162758) do
t.string "architecture"
t.boolean "run_untagged", default: true, null: false
t.boolean "locked", default: false, null: false
- t.boolean "protected", default: false, null: false
+ t.integer "access_level", default: 0, null: false
end
+ add_index "ci_runners", ["access_level"], name: "index_ci_runners_on_access_level", using: :btree
add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree
add_index "ci_runners", ["is_shared"], name: "index_ci_runners_on_is_shared", using: :btree
add_index "ci_runners", ["locked"], name: "index_ci_runners_on_locked", using: :btree