Update scripts/decomposition/generate-loose-foreign-key to be able to run with multiple databases
What does this MR do and why?
- Removes branch, and MR generation as we do not want to maintain this
- Allow script to run in multi-database mode. In order to make this work, removes the automatic test running from the script. See #361385 (comment 1024512327)
- As a semi-replacement for 1, print out the files that this script adds, or modifies
Related issue: #361385 (closed)
Screenshots or screen recordings
Example run :
Generating Loose Foreign Key for given filters: ["clusters_integration_prometheus"]
Matched: 820 (clusters_integration_prometheus, clusters, cluster_id)
Add new definition for {"table"=>"clusters", "column"=>"cluster_id", "on_delete"=>"async_delete"}.
Writing db/post_migrate/20220713021207_remove_clusters_clusters_integration_prometheus_cluster_id_fk.rb
>> bin/rails db:migrate
main: == 20220713021207 RemoveClustersClustersIntegrationPrometheusClusterIdFk: migrating
main: -- foreign_keys(:clusters_integration_prometheus)
main: -> 0.0016s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("LOCK clusters, clusters_integration_prometheus IN ACCESS EXCLUSIVE MODE")
main: -> 0.0003s
main: -- foreign_keys(:clusters_integration_prometheus)
main: -> 0.0010s
main: -- remove_foreign_key(:clusters_integration_prometheus, :clusters, {:name=>"fk_rails_e44472034c"})
main: -> 0.0015s
main: == 20220713021207 RemoveClustersClustersIntegrationPrometheusClusterIdFk: migrated (0.0078s)
ci: == 20220713021207 RemoveClustersClustersIntegrationPrometheusClusterIdFk: migrating
ci: -- foreign_keys(:clusters_integration_prometheus)
ci: -> 0.0018s
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- execute("LOCK clusters, clusters_integration_prometheus IN ACCESS EXCLUSIVE MODE")
ci: -> 0.0003s
ci: -- foreign_keys(:clusters_integration_prometheus)
ci: -> 0.0012s
ci: -- remove_foreign_key(:clusters_integration_prometheus, :clusters, {:name=>"fk_rails_e44472034c"})
ci: -> 0.0017s
ci: == 20220713021207 RemoveClustersClustersIntegrationPrometheusClusterIdFk: migrated (0.0067s)
Adding test to spec/models/clusters/integrations/prometheus_spec.rb...
Updating spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb...
Nothing changed.
The following files have been generated/modified:
/Users/tkuah/code/gdk-ee/gitlab/config/gitlab_loose_foreign_keys.yml
db/post_migrate/20220713021207_remove_clusters_clusters_integration_prometheus_cluster_id_fk.rb
spec/models/clusters/integrations/prometheus_spec.rb
(arm64) tkgl2:gitlab tkuah$ git status
On branch fix_generate_loose_foreign_key_script
Your branch is up to date with 'origin/fix_generate_loose_foreign_key_script'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: config/gitlab_loose_foreign_keys.yml
modified: db/structure.sql
modified: spec/models/clusters/integrations/prometheus_spec.rb
Untracked files:
(use "git add <file>..." to include in what will be committed)
db/post_migrate/20220713021207_remove_clusters_clusters_integration_prometheus_cluster_id_fk.rb
db/schema_migrations/20220713021207
no changes added to commit (use "git add" and/or "git commit -a")
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Thong Kuah