summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-12-15 02:56:05 +0900
committerShinya Maeda <shinya@gitlab.com>2018-01-08 16:22:17 +0900
commit40c6af546e3a941f829bf91435e848c22bf2aed8 (patch)
treee2f011e57903734f955c96f5ee10464784e2061a /db
parentb9fbfe5a6b21bed39010224fd012366d3d39b117 (diff)
downloadgitlab-ce-40c6af546e3a941f829bf91435e848c22bf2aed8.tar.gz
Fix migration file typos and reorder Table definition
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb46
1 files changed, 21 insertions, 25 deletions
diff --git a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
index 4b9e3094f94..7c7e5046ec8 100644
--- a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
+++ b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
@@ -2,6 +2,13 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
DOWNTIME = false
DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME = 'KubernetesService'.freeze
+ class Project < ActiveRecord::Base
+ self.table_name = 'projects'
+
+ has_many :cluster_projects, class_name: 'ClustersProject'
+ has_many :clusters, through: :cluster_projects, class_name: 'Cluster'
+ end
+
class Cluster < ActiveRecord::Base
self.table_name = 'clusters'
@@ -9,11 +16,6 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
has_many :projects, through: :cluster_projects, class_name: 'Project'
has_one :platform_kubernetes, class_name: 'PlatformsKubernetes'
- attr_encrypted :token,
- mode: :per_attribute_iv,
- key: Gitlab::Application.secrets.db_key_base,
- algorithm: 'aes-256-cbc'
-
accepts_nested_attributes_for :platform_kubernetes
enum platform_type: {
@@ -26,11 +28,20 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
}
end
- class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ class ClustersProject < ActiveRecord::Base
+ self.table_name = 'cluster_projects'
- has_many :cluster_projects, class_name: 'ClustersProject'
- has_many :clusters, through: :cluster_projects, class_name: 'Cluster'
+ belongs_to :cluster, class_name: 'Cluster'
+ belongs_to :project, class_name: 'Project'
+ end
+
+ class PlatformsKubernetes < ActiveRecord::Base
+ self.table_name = 'cluster_platforms_kubernetes'
+
+ attr_encrypted :token,
+ mode: :per_attribute_iv,
+ key: Gitlab::Application.secrets.db_key_base,
+ algorithm: 'aes-256-cbc'
end
class Service < ActiveRecord::Base
@@ -67,21 +78,6 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
end
end
- class ClustersProject < ActiveRecord::Base
- self.table_name = 'cluster_projects'
-
- belongs_to :cluster, class_name: 'Cluster'
- belongs_to :project, class_name: 'Project'
- end
-
- class ProvidersGcp < ActiveRecord::Base
- self.table_name = 'cluster_providers_gcp'
- end
-
- class PlatformsKubernetes < ActiveRecord::Base
- self.table_name = 'cluster_platforms_kubernetes'
- end
-
def up
Service.unmanaged_kubernetes_service
.find_each(batch_size: 1) do |kubernetes_service|
@@ -104,7 +100,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
# Disable the KubernetesService. Platforms::Kubernetes will be used from next time.
kubernetes_service.active = false
- kubernetes_service.propaties.merge!( { migrated: true } )
+ kubernetes_service.properties.merge!( { migrated: true } )
kubernetes_service.save!
end
end