diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-01-03 23:44:08 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-01-08 16:22:17 +0900 |
commit | 9b7719b6c60f2ba9a2e8e6ded543bb4fb87cd11b (patch) | |
tree | 502a3dc67cb607ad8ca0f40e304ce35f4e19de3d | |
parent | f083739e9935f774984f4c8ba2ce4663c29c7564 (diff) | |
download | gitlab-ce-9b7719b6c60f2ba9a2e8e6ded543bb4fb87cd11b.tar.gz |
Use explicit namespace for avoiding reference from application code
-rw-r--r-- | db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb | 29 |
1 files changed, 16 insertions, 13 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 46b40ea7a44..da34880b4e1 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 @@ -5,16 +5,17 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati class Project < ActiveRecord::Base self.table_name = 'projects' - has_many :cluster_projects, class_name: 'ClustersProject' - has_many :clusters, through: :cluster_projects, class_name: 'Cluster' + has_many :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject' + has_many :clusters, through: :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' + has_many :services, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Service' end class Cluster < ActiveRecord::Base self.table_name = 'clusters' - has_many :cluster_projects, class_name: 'ClustersProject' - has_many :projects, through: :cluster_projects, class_name: 'Project' - has_one :platform_kubernetes, class_name: 'PlatformsKubernetes' + has_many :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject' + has_many :projects, through: :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project' + has_one :platform_kubernetes, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::PlatformsKubernetes' accepts_nested_attributes_for :platform_kubernetes @@ -31,13 +32,15 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati class ClustersProject < ActiveRecord::Base self.table_name = 'cluster_projects' - belongs_to :cluster, class_name: 'Cluster' - belongs_to :project, class_name: 'Project' + belongs_to :cluster, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' + belongs_to :project, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project' end class PlatformsKubernetes < ActiveRecord::Base self.table_name = 'cluster_platforms_kubernetes' + belongs_to :cluster, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' + attr_encrypted :token, mode: :per_attribute_iv, key: Gitlab::Application.secrets.db_key_base, @@ -49,7 +52,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati self.table_name = 'services' - belongs_to :project, class_name: 'Project' + belongs_to :project, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project' scope :kubernetes_service, -> do where("services.category = 'deployment'") @@ -84,15 +87,15 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati end def up - Service.kubernetes_service.find_each(batch_size: 1) do |kubernetes_service| + MigrateKubernetesServiceToNewClustersArchitectures::Service.kubernetes_service.find_each(batch_size: 1) do |kubernetes_service| unless managed_by_clusters?(kubernetes_service) - Cluster.create( + MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create( enabled: kubernetes_service.active, user_id: nil, # KubernetesService doesn't have name: DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME, - provider_type: Cluster.provider_types[:user], - platform_type: Cluster.platform_types[:kubernetes], - projects: [kubernetes_service.project], + provider_type: MigrateKubernetesServiceToNewClustersArchitectures::Cluster.provider_types[:user], + platform_type: MigrateKubernetesServiceToNewClustersArchitectures::Cluster.platform_types[:kubernetes], + projects: [kubernetes_service.project.becomes(MigrateKubernetesServiceToNewClustersArchitectures::Project)], environment_scope: find_dedicated_environement_scope(kubernetes_service.project), platform_kubernetes_attributes: { api_url: kubernetes_service.api_url, |