diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2019-04-02 09:54:54 +0300 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-04-02 09:54:54 +0300 |
commit | 6473f6976124f047a56f9d004e3d0746ab493b29 (patch) | |
tree | a4d157a4a436d1a0151651b17ac4e9790b124ef7 | |
parent | c44b9e9e5b79c4012a0fea8743fc058a444234d0 (diff) |
Add new field to Clusters table
Adds boolean field 'managed' to clusters table. This new column will be
used to distinguish those clusters that are automatically managed by
gitlab.
Needed for https://gitlab.com/gitlab-org/gitlab-ce/issues/56557
-rw-r--r-- | db/migrate/20190325165127_add_managed_to_cluster.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 3 | ||||
-rw-r--r-- | spec/factories/clusters/clusters.rb | 5 |
3 files changed, 24 insertions, 1 deletions
diff --git a/db/migrate/20190325165127_add_managed_to_cluster.rb b/db/migrate/20190325165127_add_managed_to_cluster.rb new file mode 100644 index 00000000000..e960df9d502 --- /dev/null +++ b/db/migrate/20190325165127_add_managed_to_cluster.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddManagedToCluster < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + DOWNTIME = false + + def up + add_column_with_default(:clusters, :managed, :boolean, default: true) + end + + def down + remove_column(:clusters, :managed) + end +end diff --git a/db/schema.rb b/db/schema.rb index 7cc09e56285..8197e860996 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190322132835) do +ActiveRecord::Schema.define(version: 20190325165127) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -670,6 +670,7 @@ ActiveRecord::Schema.define(version: 20190322132835) do t.string "environment_scope", default: "*", null: false t.integer "cluster_type", limit: 2, default: 3, null: false t.string "domain" + t.boolean "managed", default: true, null: false t.index ["enabled"], name: "index_clusters_on_enabled", using: :btree t.index ["user_id"], name: "index_clusters_on_user_id", using: :btree end diff --git a/spec/factories/clusters/clusters.rb b/spec/factories/clusters/clusters.rb index 1cc3c0e03d8..97405ec7c58 100644 --- a/spec/factories/clusters/clusters.rb +++ b/spec/factories/clusters/clusters.rb @@ -3,6 +3,7 @@ FactoryBot.define do user name 'test-cluster' cluster_type :project_type + managed true trait :instance do cluster_type { Clusters::Cluster.cluster_types[:instance_type] } @@ -63,5 +64,9 @@ FactoryBot.define do trait :with_domain do domain 'example.com' end + + trait :user_managed do + managed false + end end end |