Commit 5f77cd81 authored by Patrick Bair's avatar Patrick Bair

Merge branch '351833-sort-loose-foreign-keys-yaml-file' into 'master'

Sorting the keys of the file gitlab_loose_foreign_keys.yml

See merge request gitlab-org/gitlab!80524
parents 74bbdea9 570bb908
# Make sure that this file has the keys sorted
--- ---
dast_site_profiles_pipelines: ci_build_report_results:
- table: ci_pipelines
column: ci_pipeline_id
on_delete: async_delete
vulnerability_feedback:
- table: ci_pipelines
column: pipeline_id
on_delete: async_nullify
ci_pipeline_chat_data:
- table: chat_names
column: chat_name_id
on_delete: async_delete
dast_scanner_profiles_builds:
- table: ci_builds
column: ci_build_id
on_delete: async_delete
dast_site_profiles_builds:
- table: ci_builds
column: ci_build_id
on_delete: async_delete
dast_profiles_pipelines:
- table: ci_pipelines
column: ci_pipeline_id
on_delete: async_delete
clusters_applications_runners:
- table: ci_runners
column: runner_id
on_delete: async_nullify
ci_variables:
- table: projects
column: project_id
on_delete: async_delete
ci_runner_projects:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_job_token_project_scope_links: ci_builds:
- table: users - table: users
column: added_by_id column: user_id
on_delete: async_nullify on_delete: async_nullify
- table: projects - table: projects
column: source_project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_builds_metadata:
- table: projects - table: projects
column: target_project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_daily_build_group_report_results: ci_daily_build_group_report_results:
- table: namespaces - table: namespaces
...@@ -52,52 +22,54 @@ ci_daily_build_group_report_results: ...@@ -52,52 +22,54 @@ ci_daily_build_group_report_results:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
external_pull_requests:
- table: projects
column: project_id
on_delete: async_delete
ci_freeze_periods: ci_freeze_periods:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_pending_builds: ci_group_variables:
- table: namespaces - table: namespaces
column: namespace_id column: group_id
on_delete: async_delete on_delete: async_delete
ci_job_artifacts:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_resource_groups: ci_job_token_project_scope_links:
- table: users
column: added_by_id
on_delete: async_nullify
- table: projects - table: projects
column: project_id column: source_project_id
on_delete: async_delete on_delete: async_delete
ci_runner_namespaces: - table: projects
column: target_project_id
on_delete: async_delete
ci_minutes_additional_packs:
- table: namespaces - table: namespaces
column: namespace_id column: namespace_id
on_delete: async_delete on_delete: async_delete
ci_running_builds:
- table: projects
column: project_id
on_delete: async_delete
ci_namespace_mirrors: ci_namespace_mirrors:
- table: namespaces - table: namespaces
column: namespace_id column: namespace_id
on_delete: async_delete on_delete: async_delete
ci_sources_projects: ci_pending_builds:
- table: projects - table: namespaces
column: source_project_id column: namespace_id
on_delete: async_delete on_delete: async_delete
ci_build_report_results:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_job_artifacts: ci_pipeline_artifacts:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_builds: ci_pipeline_chat_data:
- table: chat_names
column: chat_name_id
on_delete: async_delete
ci_pipeline_schedules:
- table: users - table: users
column: user_id column: owner_id
on_delete: async_nullify on_delete: async_nullify
- table: projects - table: projects
column: project_id column: project_id
...@@ -122,81 +94,49 @@ ci_project_mirrors: ...@@ -122,81 +94,49 @@ ci_project_mirrors:
- table: namespaces - table: namespaces
column: namespace_id column: namespace_id
on_delete: async_delete on_delete: async_delete
ci_unit_tests: ci_project_monthly_usages:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
merge_requests: ci_refs:
- table: ci_pipelines - table: projects
column: head_pipeline_id column: project_id
on_delete: async_nullify
vulnerability_statistics:
- table: ci_pipelines
column: latest_pipeline_id
on_delete: async_nullify
vulnerability_occurrence_pipelines:
- table: ci_pipelines
column: pipeline_id
on_delete: async_delete on_delete: async_delete
packages_build_infos: ci_resource_groups:
- table: ci_pipelines
column: pipeline_id
on_delete: async_nullify
packages_package_file_build_infos:
- table: ci_pipelines
column: pipeline_id
on_delete: async_nullify
ci_project_monthly_usages:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
pages_deployments: ci_runner_namespaces:
- table: ci_builds - table: namespaces
column: ci_build_id column: namespace_id
on_delete: async_nullify on_delete: async_delete
ci_builds_metadata: ci_runner_projects:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
terraform_state_versions: ci_running_builds:
- table: ci_builds - table: projects
column: ci_build_id column: project_id
on_delete: async_nullify
merge_request_metrics:
- table: ci_pipelines
column: pipeline_id
on_delete: async_delete on_delete: async_delete
project_pages_metadata: ci_secure_files:
- table: ci_job_artifacts
column: artifacts_archive_id
on_delete: async_nullify
ci_pipeline_schedules:
- table: users
column: owner_id
on_delete: async_nullify
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
merge_trains: ci_sources_pipelines:
- table: ci_pipelines - table: projects
column: pipeline_id column: source_project_id
on_delete: async_nullify on_delete: async_delete
ci_refs:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_group_variables: ci_sources_projects:
- table: namespaces - table: projects
column: group_id column: source_project_id
on_delete: async_delete on_delete: async_delete
ci_minutes_additional_packs: ci_stages:
- table: namespaces - table: projects
column: namespace_id column: project_id
on_delete: async_delete on_delete: async_delete
requirements_management_test_reports:
- table: ci_builds
column: build_id
on_delete: async_nullify
ci_subscriptions_projects: ci_subscriptions_projects:
- table: projects - table: projects
column: downstream_project_id column: downstream_project_id
...@@ -204,33 +144,94 @@ ci_subscriptions_projects: ...@@ -204,33 +144,94 @@ ci_subscriptions_projects:
- table: projects - table: projects
column: upstream_project_id column: upstream_project_id
on_delete: async_delete on_delete: async_delete
security_scans: ci_triggers:
- table: ci_builds - table: users
column: build_id column: owner_id
on_delete: async_delete on_delete: async_delete
ci_secure_files:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_pipeline_artifacts: ci_unit_tests:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_sources_pipelines: ci_variables:
- table: projects
column: source_project_id
on_delete: async_delete
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
ci_stages: clusters_applications_runners:
- table: projects - table: ci_runners
column: project_id column: runner_id
on_delete: async_nullify
dast_profiles_pipelines:
- table: ci_pipelines
column: ci_pipeline_id
on_delete: async_delete on_delete: async_delete
ci_triggers: dast_scanner_profiles_builds:
- table: users - table: ci_builds
column: owner_id column: ci_build_id
on_delete: async_delete
dast_site_profiles_builds:
- table: ci_builds
column: ci_build_id
on_delete: async_delete
dast_site_profiles_pipelines:
- table: ci_pipelines
column: ci_pipeline_id
on_delete: async_delete on_delete: async_delete
external_pull_requests:
- table: projects - table: projects
column: project_id column: project_id
on_delete: async_delete on_delete: async_delete
merge_request_metrics:
- table: ci_pipelines
column: pipeline_id
on_delete: async_delete
merge_requests:
- table: ci_pipelines
column: head_pipeline_id
on_delete: async_nullify
merge_trains:
- table: ci_pipelines
column: pipeline_id
on_delete: async_nullify
packages_build_infos:
- table: ci_pipelines
column: pipeline_id
on_delete: async_nullify
packages_package_file_build_infos:
- table: ci_pipelines
column: pipeline_id
on_delete: async_nullify
pages_deployments:
- table: ci_builds
column: ci_build_id
on_delete: async_nullify
project_pages_metadata:
- table: ci_job_artifacts
column: artifacts_archive_id
on_delete: async_nullify
requirements_management_test_reports:
- table: ci_builds
column: build_id
on_delete: async_nullify
security_scans:
- table: ci_builds
column: build_id
on_delete: async_delete
terraform_state_versions:
- table: ci_builds
column: ci_build_id
on_delete: async_nullify
vulnerability_feedback:
- table: ci_pipelines
column: pipeline_id
on_delete: async_nullify
vulnerability_occurrence_pipelines:
- table: ci_pipelines
column: pipeline_id
on_delete: async_delete
vulnerability_statistics:
- table: ci_pipelines
column: latest_pipeline_id
on_delete: async_nullify
...@@ -18,6 +18,15 @@ RSpec.describe Gitlab::Database::LooseForeignKeys do ...@@ -18,6 +18,15 @@ RSpec.describe Gitlab::Database::LooseForeignKeys do
)) ))
end end
context 'ensure keys are sorted' do
it 'does not have any keys that are out of order' do
parsed = YAML.parse_file(described_class.loose_foreign_keys_yaml_path)
mapping = parsed.children.first
table_names = mapping.children.select(&:scalar?).map(&:value)
expect(table_names).to eq(table_names.sort), "expected sorted table names in the YAML file"
end
end
context 'ensure no duplicates are found' do context 'ensure no duplicates are found' do
it 'does not have duplicate tables defined' do it 'does not have duplicate tables defined' do
# since we use hash to detect duplicate hash keys we need to parse YAML document # since we use hash to detect duplicate hash keys we need to parse YAML document
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment