Project

General

Profile

Actions

Bug #23208

open

Validate existing FK relationships

Added by Andrew Kofink over 6 years ago. Updated over 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Use the association_exists_validator that was added in #21829. A quick grep shows the following list:

grep "belongs_to " -R app/models

app/models/katello/repository_deb.rb:    belongs_to :repository, :inverse_of => :repository_debs, :class_name => 'Katello::Repository'
app/models/katello/repository_deb.rb:    belongs_to :deb, :inverse_of => :repository_debs, :class_name => 'Katello::Deb'
app/models/katello/capsule_lifecycle_environment.rb:    belongs_to :capsule, :class_name => "::SmartProxy", :inverse_of => :capsule_lifecycle_environments
app/models/katello/capsule_lifecycle_environment.rb:    belongs_to :lifecycle_environment, :class_name => "Katello::KTEnvironment", :inverse_of => :capsule_lifecycle_environments
app/models/katello/concerns/container_extensions.rb:        belongs_to :capsule, :inverse_of => :containers, :foreign_key => :capsule_id,
app/models/katello/concerns/hostgroup_extensions.rb:        belongs_to :kickstart_repository, :class_name => "::Katello::Repository",
app/models/katello/concerns/hostgroup_extensions.rb:        belongs_to :content_source, :class_name => "::SmartProxy", :foreign_key => :content_source_id, :inverse_of => :hostgroups
app/models/katello/concerns/hostgroup_extensions.rb:        belongs_to :content_view, :inverse_of => :hostgroups, :class_name => "::Katello::ContentView" 
app/models/katello/concerns/hostgroup_extensions.rb:        belongs_to :lifecycle_environment, :inverse_of => :hostgroups, :class_name => "::Katello::KTEnvironment" 
app/models/katello/content_facet_applicable_rpm.rb:    belongs_to :content_facet, :inverse_of => :content_facet_applicable_rpms, :class_name => 'Katello::Host::ContentFacet'
app/models/katello/content_facet_applicable_rpm.rb:    belongs_to :rpm, :inverse_of => :content_facet_applicable_rpms, :class_name => 'Katello::Rpm'
app/models/katello/content_facet_erratum.rb:    belongs_to :content_facet, :inverse_of => :content_facet_errata, :class_name => 'Katello::Host::ContentFacet'
app/models/katello/content_facet_erratum.rb:    belongs_to :erratum, :inverse_of => :content_facet_errata, :class_name => 'Katello::Erratum'
app/models/katello/content_facet_repository.rb:    belongs_to :content_facet, :inverse_of => :content_facet_repositories, :class_name => 'Katello::Host::ContentFacet'
app/models/katello/content_facet_repository.rb:    belongs_to :repository, :inverse_of => :content_facet_repositories, :class_name => 'Katello::Repository'
app/models/katello/product_content.rb:    belongs_to :product, :class_name => 'Katello::Product', :foreign_key => 'product_id', :inverse_of => :product_contents
app/models/katello/product_content.rb:    belongs_to :content, :class_name => 'Katello::Content', :foreign_key => 'content_id', :inverse_of => :product_contents
app/models/katello/repository_srpm.rb:    belongs_to :repository, :inverse_of => :repository_srpms, :class_name => 'Katello::Repository'
app/models/katello/repository_srpm.rb:    belongs_to :srpm, :inverse_of => :repository_srpms, :class_name => 'Katello::Srpm'
app/models/katello/content_view_docker_filter_rule.rb:    belongs_to :filter,
app/models/katello/content_view_environment.rb:    belongs_to :content_view, :class_name => "Katello::ContentView", :inverse_of => :content_view_environments
app/models/katello/content_view_environment.rb:    belongs_to :environment, :class_name => "Katello::KTEnvironment", :inverse_of => :content_view_environments
app/models/katello/content_view_environment.rb:    belongs_to :content_view_version, :class_name => "Katello::ContentViewVersion",
app/models/katello/content_view_version.rb:    belongs_to :content_view, :class_name => "Katello::ContentView", :inverse_of => :content_view_versions
app/models/katello/content_view_erratum_filter_rule.rb:    belongs_to :filter,
app/models/katello/content_view_filter.rb:    belongs_to :content_view,
app/models/katello/content_view_package_filter_rule.rb:    belongs_to :filter,
app/models/katello/content_view_package_group_filter_rule.rb:    belongs_to :filter,
app/models/katello/docker_meta_tag.rb:    belongs_to :repository, :inverse_of => :docker_meta_tags, :class_name => "Katello::Repository" 
app/models/katello/docker_meta_tag.rb:    belongs_to :schema1, :class_name => "Katello::DockerTag",
app/models/katello/docker_meta_tag.rb:    belongs_to :schema2, :class_name => "Katello::DockerTag",
app/models/katello/content_view_puppet_environment_puppet_module.rb:    belongs_to :content_view_puppet_environment,
app/models/katello/content_view_puppet_environment_puppet_module.rb:    belongs_to :puppet_module,
app/models/katello/content_view_puppet_module.rb:    belongs_to :content_view, :class_name => "Katello::ContentView", :inverse_of => :content_view_versions
app/models/katello/subscription.rb:    belongs_to :organization, :class_name => "Organization", :inverse_of => :subscriptions
app/models/katello/content_view_version_component.rb:    belongs_to :composite_version, :class_name => "Katello::ContentViewVersion", :inverse_of => :content_view_version_components
app/models/katello/content_view_version_component.rb:    belongs_to :component_version, :class_name => "Katello::ContentViewVersion", :inverse_of => :content_view_version_composites
app/models/katello/repository.rb:    belongs_to :environment, :inverse_of => :repositories, :class_name => "Katello::KTEnvironment" 
app/models/katello/repository.rb:    belongs_to :product, :inverse_of => :repositories
app/models/katello/repository.rb:    belongs_to :gpg_key, :inverse_of => :repositories
app/models/katello/repository.rb:    belongs_to :ssl_ca_cert, :class_name => "Katello::GpgKey", :inverse_of => :ssl_ca_repos
app/models/katello/repository.rb:    belongs_to :ssl_client_cert, :class_name => "Katello::GpgKey", :inverse_of => :ssl_client_repos
app/models/katello/repository.rb:    belongs_to :ssl_client_key, :class_name => "Katello::GpgKey", :inverse_of => :ssl_key_repos
app/models/katello/repository.rb:    belongs_to :library_instance, :class_name => "Katello::Repository", :inverse_of => :library_instances_inverse
app/models/katello/repository.rb:    belongs_to :content_view_version, :inverse_of => :repositories, :class_name => "Katello::ContentViewVersion" 
app/models/katello/content_view_history.rb:    belongs_to :environment, :class_name => "Katello::KTEnvironment", :inverse_of => :content_view_histories,
app/models/katello/content_view_history.rb:    belongs_to :content_view_version, :class_name => "Katello::ContentViewVersion", :foreign_key => :katello_content_view_version_id, :inverse_of => :history
app/models/katello/content_view_history.rb:    belongs_to :triggered_by, :class_name => "Katello::ContentViewVersion", :inverse_of => :triggered_histories
app/models/katello/content_view_history.rb:    belongs_to :task, :class_name => "ForemanTasks::Task::DynflowTask", :foreign_key => :task_id
app/models/katello/content_view_repository.rb:    belongs_to :content_view, :inverse_of => :content_view_repositories,
app/models/katello/content_view_repository.rb:    belongs_to :repository, :inverse_of => :content_view_repositories,
app/models/katello/erratum_bugzilla.rb:    belongs_to :erratum, :inverse_of => :bugzillas, :class_name => 'Katello::Erratum'
app/models/katello/erratum_cve.rb:    belongs_to :erratum, :inverse_of => :cves, :class_name => 'Katello::Erratum'
app/models/katello/erratum_package.rb:    belongs_to :erratum, :inverse_of => :packages, :class_name => 'Katello::Erratum'
app/models/katello/host/content_facet.rb:      belongs_to :kickstart_repository, :class_name => "::Katello::Repository", :foreign_key => :kickstart_repository_id, :inverse_of => :kickstart_content_facets
app/models/katello/host/content_facet.rb:      belongs_to :content_view, :inverse_of => :content_facets, :class_name => "Katello::ContentView" 
app/models/katello/host/content_facet.rb:      belongs_to :lifecycle_environment, :inverse_of => :content_facets, :class_name => "Katello::KTEnvironment" 
app/models/katello/host/content_facet.rb:      belongs_to :content_source, :class_name => "::SmartProxy", :foreign_key => :content_source_id, :inverse_of => :content_facets
app/models/katello/host/subscription_facet.rb:      belongs_to :user, :inverse_of => :subscription_facets, :class_name => "::User" 
app/models/katello/host/subscription_facet.rb:      belongs_to :hypervisor_host, :class_name => "::Host::Managed", :foreign_key => "hypervisor_host_id" 
app/models/katello/host_collection.rb:    belongs_to :organization, :inverse_of => :host_collections
app/models/katello/host_collection_hosts.rb:    belongs_to :host, :inverse_of => :host_collection_hosts, :class_name => 'Host::Managed'
app/models/katello/host_collection_hosts.rb:    belongs_to :host_collection, :inverse_of => :host_collection_hosts
app/models/katello/host_tracer.rb:    belongs_to :host, :inverse_of => :host_traces, :class_name => '::Host::Managed'
app/models/katello/key_host_collection.rb:    belongs_to :activation_key, :inverse_of => :key_host_collections
app/models/katello/key_host_collection.rb:    belongs_to :host_collection, :inverse_of => :key_host_collections
app/models/katello/content_view_puppet_environment.rb:    belongs_to :environment, :class_name => "Katello::KTEnvironment",
app/models/katello/content_view_puppet_environment.rb:    belongs_to :content_view_version, :class_name => "Katello::ContentViewVersion",
app/models/katello/content_view_puppet_environment.rb:    belongs_to :puppet_environment, :class_name => "Environment",
app/models/katello/pool_activation_key.rb:    belongs_to :pool, :inverse_of => :pool_activation_keys, :class_name => 'Katello::Pool'
app/models/katello/pool_activation_key.rb:    belongs_to :activation_key, :inverse_of => :pool_activation_keys, :class_name => 'Katello::ActivationKey'
app/models/katello/compliance_reason.rb:    belongs_to :subscription_facet, :inverse_of => :compliance_reasons, :class_name => 'Katello::Host::SubscriptionFacet'
app/models/katello/pool.rb:    belongs_to :subscription, :inverse_of => :pools, :class_name => "Katello::Subscription" 
app/models/katello/repository_docker_manifest.rb:    belongs_to :repository, :inverse_of => :repository_docker_manifests, :class_name => 'Katello::Repository'
app/models/katello/repository_docker_manifest.rb:    belongs_to :docker_manifest, :inverse_of => :repository_docker_manifests
app/models/katello/docker_tag.rb:    belongs_to :docker_taggable, :polymorphic => true, :inverse_of => :docker_tags
app/models/katello/docker_tag.rb:    belongs_to :repository, :inverse_of => :docker_tags, :class_name => "Katello::Repository" 
app/models/katello/repository_erratum.rb:    belongs_to :repository, :inverse_of => :repository_errata, :class_name => 'Katello::Repository'
app/models/katello/repository_erratum.rb:    belongs_to :erratum, :inverse_of => :repository_errata, :class_name => 'Katello::Erratum'
app/models/katello/repository_file.rb:    belongs_to :repository, :inverse_of => :repository_files, :class_name => 'Katello::Repository'
app/models/katello/repository_file.rb:    belongs_to :file, :inverse_of => :repository_files, :class_name => 'Katello::FileUnit', :foreign_key => :file_id
app/models/katello/repository_ostree_branch.rb:    belongs_to :repository, :inverse_of => :repository_ostree_branches, :class_name => 'Katello::Repository'
app/models/katello/repository_ostree_branch.rb:    belongs_to :ostree_branch, :inverse_of => :repository_ostree_branches
app/models/katello/repository_package_group.rb:    belongs_to :repository, :inverse_of => :repository_package_groups, :class_name => 'Katello::Repository'
app/models/katello/repository_package_group.rb:    belongs_to :package_group, :inverse_of => :repository_package_groups, :class_name => 'Katello::PackageGroup'
app/models/katello/repository_puppet_module.rb:    belongs_to :repository, :inverse_of => :repository_puppet_modules, :class_name => 'Katello::Repository'
app/models/katello/repository_puppet_module.rb:    belongs_to :puppet_module, :inverse_of => :repository_puppet_modules, :class_name => 'Katello::PuppetModule'
app/models/katello/repository_rpm.rb:    belongs_to :repository, :inverse_of => :repository_rpms, :class_name => 'Katello::Repository'
app/models/katello/repository_rpm.rb:    belongs_to :rpm, :inverse_of => :repository_rpms, :class_name => 'Katello::Rpm'
app/models/katello/sync_plan.rb:    belongs_to :organization, :inverse_of => :sync_plans
app/models/katello/subscription_facet_pool.rb:    belongs_to :subscription_facet, :inverse_of => :subscription_facet_pools, :class_name => 'Katello::Host::SubscriptionFacet'
app/models/katello/subscription_facet_pool.rb:    belongs_to :pool, :inverse_of => :subscription_facet_pools, :class_name => 'Katello::Pool'
app/models/katello/subscription_facet_activation_key.rb:    belongs_to :subscription_facet, :inverse_of => :subscription_facet_activation_keys, :class_name => 'Katello::Host::SubscriptionFacet'
app/models/katello/subscription_facet_activation_key.rb:    belongs_to :activation_key, :inverse_of => :subscription_facet_activation_keys, :class_name => 'Katello::ActivationKey'
app/models/katello/gpg_key.rb:    belongs_to :organization, :inverse_of => :gpg_keys
app/models/katello/subscription_product.rb:    belongs_to :product, :inverse_of => :subscription_products, :class_name => 'Katello::Product'
app/models/katello/subscription_product.rb:    belongs_to :subscription, :inverse_of => :subscription_products, :class_name => 'Katello::Subscription'
app/models/katello/task_status.rb:    belongs_to :organization, :inverse_of => :task_statuses, :class_name => "Organization" 
app/models/katello/task_status.rb:    belongs_to :user, :inverse_of => :task_statuses, :class_name => "::User" 
app/models/katello/task_status.rb:    belongs_to :task_owner, :polymorphic => true
app/models/katello/activation_key.rb:    belongs_to :organization, :inverse_of => :activation_keys
app/models/katello/activation_key.rb:    belongs_to :environment, :class_name => "KTEnvironment", :inverse_of => :activation_keys
app/models/katello/activation_key.rb:    belongs_to :user, :inverse_of => :activation_keys, :class_name => "::User" 
app/models/katello/activation_key.rb:    belongs_to :content_view, :inverse_of => :activation_keys
app/models/katello/content_view.rb:    belongs_to :organization, :inverse_of => :content_views, :class_name => "::Organization" 
app/models/katello/host_installed_package.rb:    belongs_to :host, :inverse_of => :host_installed_packages, :class_name => '::Host::Managed'
app/models/katello/host_installed_package.rb:    belongs_to :installed_package, :inverse_of => :host_installed_packages, :class_name => 'Katello::InstalledPackage'
app/models/katello/provider.rb:    belongs_to :organization, :inverse_of => :providers, :class_name => "Organization" 
app/models/katello/provider.rb:    belongs_to :task_status, :inverse_of => :provider
app/models/katello/kt_environment.rb:    belongs_to :organization, :class_name => "Organization", :inverse_of => :environments
app/models/katello/product.rb:    belongs_to :organization, :inverse_of => :products
app/models/katello/product.rb:    belongs_to :provider, :inverse_of => :products
app/models/katello/product.rb:    belongs_to :sync_plan, :inverse_of => :products, :class_name => 'Katello::SyncPlan'
app/models/katello/product.rb:    belongs_to :gpg_key, :inverse_of => :products
app/models/katello/product.rb:    belongs_to :ssl_ca_cert, :class_name => "Katello::GpgKey", :inverse_of => :ssl_ca_products
app/models/katello/product.rb:    belongs_to :ssl_client_cert, :class_name => "Katello::GpgKey", :inverse_of => :ssl_client_products
app/models/katello/product.rb:    belongs_to :ssl_client_key, :class_name => "Katello::GpgKey", :inverse_of => :ssl_key_products
app/models/katello/content_view_component.rb:    belongs_to :composite_content_view, :class_name => "Katello::ContentView",
app/models/katello/content_view_component.rb:    belongs_to :content_view_version, :class_name => "Katello::ContentViewVersion",
app/models/katello/content_view_component.rb:    belongs_to :content_view, :class_name => "Katello::ContentView",
app/models/katello/docker_manifest_list_manifest.rb:    belongs_to :docker_manifest, :inverse_of => :docker_manifest_list_manifests, :class_name => 'Katello::DockerManifest'
app/models/katello/docker_manifest_list_manifest.rb:    belongs_to :docker_manifest_list, :inverse_of => :docker_manifest_list_manifests, :class_name => 'Katello::DockerManifestList'
app/models/katello/repository_docker_manifest_list.rb:    belongs_to :repository, :inverse_of => :repository_docker_manifest_lists, :class_name => 'Katello::Repository'
app/models/katello/repository_docker_manifest_list.rb:    belongs_to :docker_manifest_list, :inverse_of => :repository_docker_manifest_lists
app/models/katello/subscription_facet_installed_product.rb:    belongs_to :subscription_facet, :inverse_of => :subscription_facet_installed_products, :class_name => 'Katello::Host::SubscriptionFacet'
app/models/katello/subscription_facet_installed_product.rb:    belongs_to :installed_product, :inverse_of => :subscription_facet_installed_products, :class_name => 'Katello::InstalledProduct'

Related issues 2 (1 open1 closed)

Related to Katello - Bug #23209: Validate existing FK relationshipsNewActions
Blocked by Foreman - Bug #21829: Specifying wrong foreign key id for object (such as host or hostgroup) via hammer/api throws SQL errorClosedAndrew Kofink11/16/2017Actions
Actions

Also available in: Atom PDF