remove_foreign_keys

in db/migrate/20190402150158_backport_enterprise_schema.rb [1996:2141]


  def remove_foreign_keys
    remove_foreign_key_without_error("application_settings", column: "custom_project_templates_group_id")
    remove_foreign_key_without_error("application_settings", column: "file_template_project_id")
    remove_foreign_key_without_error("approval_merge_request_rule_sources", column: "approval_merge_request_rule_id")
    remove_foreign_key_without_error("approval_merge_request_rule_sources", column: "approval_project_rule_id")
    remove_foreign_key_without_error("approval_merge_request_rules", column: "merge_request_id")
    remove_foreign_key_without_error("approval_merge_request_rules_approved_approvers", column: "approval_merge_request_rule_id")
    remove_foreign_key_without_error("approval_merge_request_rules_approved_approvers", column: "user_id")
    remove_foreign_key_without_error("approval_merge_request_rules_groups", column: "approval_merge_request_rule_id")
    remove_foreign_key_without_error("approval_merge_request_rules_groups", column: "group_id")
    remove_foreign_key_without_error("approval_merge_request_rules_users", column: "approval_merge_request_rule_id")
    remove_foreign_key_without_error("approval_merge_request_rules_users", column: "user_id")
    remove_foreign_key_without_error("approval_project_rules", column: "project_id")
    remove_foreign_key_without_error("approval_project_rules_groups", column: "approval_project_rule_id")
    remove_foreign_key_without_error("approval_project_rules_groups", column: "group_id")
    remove_foreign_key_without_error("approval_project_rules_users", column: "approval_project_rule_id")
    remove_foreign_key_without_error("approval_project_rules_users", column: "user_id")
    remove_foreign_key_without_error("approvals", column: "merge_request_id")
    remove_foreign_key_without_error("approver_groups", column: "group_id")
    remove_foreign_key_without_error("board_assignees", column: "board_id")
    remove_foreign_key_without_error("board_assignees", column: "assignee_id")
    remove_foreign_key_without_error("board_labels", column: "board_id")
    remove_foreign_key_without_error("board_labels", column: "label_id")
    remove_foreign_key_without_error("ci_sources_pipelines", column: "source_job_id")
    remove_foreign_key_without_error("ci_sources_pipelines", column: "pipeline_id")
    remove_foreign_key_without_error("ci_sources_pipelines", column: "source_pipeline_id")
    remove_foreign_key_without_error("ci_sources_pipelines", column: "source_project_id")
    remove_foreign_key_without_error("ci_sources_pipelines", column: "project_id")
    remove_foreign_key_without_error("design_management_designs", column: "issue_id")
    remove_foreign_key_without_error("design_management_designs", column: "project_id")
    remove_foreign_key_without_error("design_management_versions", column: "design_management_design_id")
    remove_foreign_key_without_error("draft_notes", column: "merge_request_id")
    remove_foreign_key_without_error("draft_notes", column: "author_id")
    remove_foreign_key_without_error("elasticsearch_indexed_namespaces", column: "namespace_id")
    remove_foreign_key_without_error("elasticsearch_indexed_projects", column: "project_id")
    remove_foreign_key_without_error("epic_issues", column: "epic_id")
    remove_foreign_key_without_error("epic_issues", column: "issue_id")
    remove_foreign_key_without_error("epic_metrics", column: "epic_id")
    remove_foreign_key_without_error("epics", column: "parent_id")
    remove_foreign_key_without_error("epics", column: "milestone_id")
    remove_foreign_key_without_error("epics", column: "group_id")
    remove_foreign_key_without_error("epics", column: "assignee_id")
    remove_foreign_key_without_error("epics", column: "author_id")
    remove_foreign_key_without_error("epics", column: "closed_by_id")
    remove_foreign_key_without_error("geo_event_log", column: "cache_invalidation_event_id")
    remove_foreign_key_without_error("geo_event_log", column: "hashed_storage_migrated_event_id")
    remove_foreign_key_without_error("geo_event_log", column: "job_artifact_deleted_event_id")
    remove_foreign_key_without_error("geo_event_log", column: "lfs_object_deleted_event_id")
    remove_foreign_key_without_error("geo_event_log", column: "repositories_changed_event_id")
    remove_foreign_key_without_error("geo_event_log", column: "repository_created_event_id")
    remove_foreign_key_without_error("geo_event_log", column: "repository_deleted_event_id")
    remove_foreign_key_without_error("geo_event_log", column: "repository_renamed_event_id")
    remove_foreign_key_without_error("geo_event_log", column: "repository_updated_event_id")
    remove_foreign_key_without_error("geo_event_log", column: "reset_checksum_event_id")
    remove_foreign_key_without_error("geo_event_log", column: "upload_deleted_event_id")
    remove_foreign_key_without_error("geo_hashed_storage_attachments_events", column: "project_id")
    remove_foreign_key_without_error("geo_hashed_storage_migrated_events", column: "project_id")
    remove_foreign_key_without_error("geo_node_namespace_links", column: "geo_node_id")
    remove_foreign_key_without_error("geo_node_namespace_links", column: "namespace_id")
    remove_foreign_key_without_error("geo_node_statuses", column: "geo_node_id")
    remove_foreign_key_without_error("geo_repositories_changed_events", column: "geo_node_id")
    remove_foreign_key_without_error("geo_repository_created_events", column: "project_id")
    remove_foreign_key_without_error("geo_repository_renamed_events", column: "project_id")
    remove_foreign_key_without_error("geo_repository_updated_events", column: "project_id")
    remove_foreign_key_without_error("geo_reset_checksum_events", column: "project_id")
    remove_foreign_key_without_error("gitlab_subscriptions", column: "namespace_id")
    remove_foreign_key_without_error("gitlab_subscriptions", column: "hosted_plan_id")
    remove_foreign_key_without_error("identities", column: "saml_provider_id")
    remove_foreign_key_without_error("index_statuses", column: "project_id")
    remove_foreign_key_without_error("insights", column: "namespace_id", on_delete: nil)
    remove_foreign_key_without_error("insights", column: "project_id", on_delete: nil)
    remove_foreign_key_without_error("issue_links", column: "source_id")
    remove_foreign_key_without_error("issue_links", column: "target_id")
    remove_foreign_key_without_error("lists", column: "milestone_id")
    remove_foreign_key_without_error("lists", column: "user_id")
    remove_foreign_key_without_error("namespace_statistics", column: "namespace_id")
    remove_foreign_key_without_error("namespaces", column: "custom_project_templates_group_id")
    remove_foreign_key_without_error("namespaces", column: "plan_id")
    remove_foreign_key_without_error("namespaces", column: "file_template_project_id")
    remove_foreign_key_without_error("notes", column: "review_id")
    remove_foreign_key_without_error("operations_feature_flag_scopes", column: "feature_flag_id")
    remove_foreign_key_without_error("operations_feature_flags", column: "project_id")
    remove_foreign_key_without_error("operations_feature_flags_clients", column: "project_id")
    remove_foreign_key_without_error("packages_maven_metadata", column: "package_id")
    remove_foreign_key_without_error("packages_package_files", column: "package_id")
    remove_foreign_key_without_error("packages_packages", column: "project_id")
    remove_foreign_key_without_error("path_locks", column: "project_id")
    remove_foreign_key_without_error("path_locks", column: "user_id", on_delete: nil)
    remove_foreign_key_without_error("project_alerting_settings", column: "project_id")
    remove_foreign_key_without_error("project_feature_usages", column: "project_id")
    remove_foreign_key_without_error("project_incident_management_settings", column: "project_id")
    remove_foreign_key_without_error("project_repository_states", column: "project_id")
    remove_foreign_key_without_error("project_tracing_settings", column: "project_id")
    remove_foreign_key_without_error("prometheus_alert_events", column: "project_id")
    remove_foreign_key_without_error("prometheus_alert_events", column: "prometheus_alert_id")
    remove_foreign_key_without_error("prometheus_alerts", column: "environment_id")
    remove_foreign_key_without_error("prometheus_alerts", column: "project_id")
    remove_foreign_key_without_error("prometheus_alerts", column: "prometheus_metric_id")
    remove_foreign_key_without_error("protected_branch_merge_access_levels", column: "group_id")
    remove_foreign_key_without_error("protected_branch_merge_access_levels", column: "user_id", on_delete: nil)
    remove_foreign_key_without_error("protected_branch_push_access_levels", column: "group_id")
    remove_foreign_key_without_error("protected_branch_push_access_levels", column: "user_id", on_delete: nil)
    remove_foreign_key_without_error("protected_branch_unprotect_access_levels", column: "group_id")
    remove_foreign_key_without_error("protected_branch_unprotect_access_levels", column: "protected_branch_id")
    remove_foreign_key_without_error("protected_branch_unprotect_access_levels", column: "user_id")
    remove_foreign_key_without_error("protected_environment_deploy_access_levels", column: "group_id")
    remove_foreign_key_without_error("protected_environment_deploy_access_levels", column: "protected_environment_id")
    remove_foreign_key_without_error("protected_environment_deploy_access_levels", column: "user_id")
    remove_foreign_key_without_error("protected_environments", column: "project_id")
    remove_foreign_key_without_error("push_rules", column: "project_id")
    remove_foreign_key_without_error("resource_label_events", column: "epic_id")
    remove_foreign_key_without_error("reviews", column: "merge_request_id")
    remove_foreign_key_without_error("reviews", column: "project_id")
    remove_foreign_key_without_error("reviews", column: "author_id")
    remove_foreign_key_without_error("saml_providers", column: "group_id")
    remove_foreign_key_without_error("scim_oauth_access_tokens", column: "group_id")
    remove_foreign_key_without_error("slack_integrations", column: "service_id")
    remove_foreign_key_without_error("smartcard_identities", column: "user_id")
    remove_foreign_key_without_error("software_license_policies", column: "project_id")
    remove_foreign_key_without_error("software_license_policies", column: "software_license_id")
    remove_foreign_key_without_error("users", column: "managing_group_id")
    remove_foreign_key_without_error("users_ops_dashboard_projects", column: "project_id")
    remove_foreign_key_without_error("users_ops_dashboard_projects", column: "user_id")
    remove_foreign_key_without_error("vulnerability_feedback", column: "pipeline_id")
    remove_foreign_key_without_error("vulnerability_feedback", column: "issue_id")
    remove_foreign_key_without_error("vulnerability_feedback", column: "merge_request_id")
    remove_foreign_key_without_error("vulnerability_feedback", column: "project_id")
    remove_foreign_key_without_error("vulnerability_feedback", column: "author_id")
    remove_foreign_key_without_error("vulnerability_identifiers", column: "project_id")
    remove_foreign_key_without_error("vulnerability_occurrence_identifiers", column: "identifier_id")
    remove_foreign_key_without_error("vulnerability_occurrence_identifiers", column: "occurrence_id")
    remove_foreign_key_without_error("vulnerability_occurrence_pipelines", column: "pipeline_id")
    remove_foreign_key_without_error("vulnerability_occurrence_pipelines", column: "occurrence_id")
    remove_foreign_key_without_error("vulnerability_occurrences", column: "project_id")
    remove_foreign_key_without_error("vulnerability_occurrences", column: "primary_identifier_id")
    remove_foreign_key_without_error("vulnerability_occurrences", column: "scanner_id")
    remove_foreign_key_without_error("vulnerability_scanners", column: "project_id")
    remove_foreign_key_without_error("dependency_proxy_blobs", column: "group_id")
    remove_foreign_key_without_error("dependency_proxy_group_settings", column: "group_id")
    remove_foreign_key_without_error("jira_connect_subscriptions", "jira_connect_installations", column: "jira_connect_installation_id")
    remove_foreign_key_without_error("jira_connect_subscriptions", "namespaces", column: "namespace_id")

    remove_foreign_key_without_error("protected_tag_create_access_levels", column: :group_id)
    add_concurrent_foreign_key("protected_tag_create_access_levels", "namespaces", column: :group_id, on_delete: nil)
  end