Remove clusters applications foreign keys
We're cleaning up the deprecated Clusters::Applications
code apropos of Remove clusters_applications_* code (#366573 - closed) In Clusters::Applications models removal (#388696 - closed) we removed the related models.
Now that the models have been removed, we want to clean up the database.
This MR's purpose is to remove the foreign keys on the related tables. The tables will be dropped after this MR is merged.
Drop Clusters::Applications related tables (!117441 - closed) is related
Migration output
main: == [advisory_lock_connection] object_id: 274100, pg_backend_pid: 30716
main: == 20230412201517 RemoveClustersApplicationsCertManagersFk: migrating =========
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:clusters_applications_cert_managers, {:column=>:cluster_id})
main: -> 0.0029s
main: == 20230412201517 RemoveClustersApplicationsCertManagersFk: migrated (0.1454s)
main: == 20230412201528 RemoveClustersApplicationsCiliumFk: migrating ===============
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:clusters_applications_cilium, {:column=>:cluster_id})
main: -> 0.0046s
main: == 20230412201528 RemoveClustersApplicationsCiliumFk: migrated (0.0204s) ======
main: == 20230412201539 RemoveClustersApplicationsCrossplaneFk: migrating ===========
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:clusters_applications_crossplane, {:column=>:cluster_id})
main: -> 0.0045s
main: == 20230412201539 RemoveClustersApplicationsCrossplaneFk: migrated (0.0226s) ==
main: == 20230412201549 RemoveClustersApplicationsHelmFk: migrating =================
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:clusters_applications_helm, {:column=>:cluster_id})
main: -> 0.0048s
main: == 20230412201549 RemoveClustersApplicationsHelmFk: migrated (0.0167s) ========
main: == 20230412201600 RemoveClustersApplicationsIngressFk: migrating ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:clusters_applications_ingress, {:column=>:cluster_id})
main: -> 0.0033s
main: == 20230412201600 RemoveClustersApplicationsIngressFk: migrated (0.0146s) =====
main: == 20230412201611 RemoveClustersApplicationsJupyterFk: migrating ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:clusters_applications_jupyter, {:column=>:cluster_id})
main: -> 0.0030s
main: == 20230412201611 RemoveClustersApplicationsJupyterFk: migrated (0.0146s) =====
main: == 20230412201621 RemoveClustersApplicationsKnativeFk: migrating ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:clusters_applications_knative, {:column=>:cluster_id})
main: -> 0.0032s
main: == 20230412201621 RemoveClustersApplicationsKnativeFk: migrated (0.0150s) =====
main: == 20230412201632 RemoveClustersApplicationsPrometheusFk: migrating ===========
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:clusters_applications_prometheus, {:column=>:cluster_id})
main: -> 0.0038s
main: == 20230412201632 RemoveClustersApplicationsPrometheusFk: migrated (0.0187s) ==
main: == 20230412201642 RemoveClustersApplicationsRunnersFk: migrating ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:clusters_applications_runners, {:column=>:cluster_id})
main: -> 0.0034s
main: == 20230412201642 RemoveClustersApplicationsRunnersFk: migrated (0.0185s) =====
main: == 20230412203234 RemoveClustersApplicationsJupyterOauthFk: migrating =========
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:clusters_applications_jupyter, {:column=>:oauth_application_id})
main: -> 0.0035s
main: == 20230412203234 RemoveClustersApplicationsJupyterOauthFk: migrated (0.0160s)
main: == 20230412204143 RemoveServerlessDomainClusterPagesFk: migrating =============
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:serverless_domain_cluster, {:column=>:pages_domain_id})
main: -> 0.0048s
main: == 20230412204143 RemoveServerlessDomainClusterPagesFk: migrated (0.0154s) ====
main: == 20230412204201 RemoveServerlessDomainClusterKnativeFk: migrating ===========
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:serverless_domain_cluster, {:column=>:clusters_applications_knative_id})
main: -> 0.0031s
main: == 20230412204201 RemoveServerlessDomainClusterKnativeFk: migrated (0.0150s) ==
main: == 20230412204224 RemoveServerlessDomainClusterCreatorFk: migrating ===========
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:serverless_domain_cluster, {:column=>:creator_id})
main: -> 0.0027s
main: == 20230412204224 RemoveServerlessDomainClusterCreatorFk: migrated (0.0148s) ==
main: == [advisory_lock_connection] object_id: 274100, pg_backend_pid: 30716
ci: == [advisory_lock_connection] object_id: 274940, pg_backend_pid: 30719
ci: == [advisory_lock_connection] object_id: 274940, pg_backend_pid: 30719
Migration Rollback output
main: == [advisory_lock_connection] object_id: 273880, pg_backend_pid: 29766
main: == 20230412204224 RemoveServerlessDomainClusterCreatorFk: reverting ===========
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE serverless_domain_cluster ADD CONSTRAINT fk_rails_fbdba67eb1 FOREIGN KEY (creator_id) REFERENCES users (id) ON DELETE SET NULL NOT VALID;")
main: -> 0.0013s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0002s
main: -- execute("ALTER TABLE serverless_domain_cluster VALIDATE CONSTRAINT fk_rails_fbdba67eb1;")
main: -> 0.0023s
main: -- execute("RESET statement_timeout")
main: -> 0.0005s
main: == 20230412204224 RemoveServerlessDomainClusterCreatorFk: reverted (0.1167s) ==
main: == 20230412204201 RemoveServerlessDomainClusterKnativeFk: reverting ===========
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE serverless_domain_cluster ADD CONSTRAINT fk_rails_e59e868733 FOREIGN KEY (clusters_applications_knative_id) REFERENCES clusters_applications_knative (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0007s
main: -- execute("ALTER TABLE serverless_domain_cluster VALIDATE CONSTRAINT fk_rails_e59e868733;")
main: -> 0.0010s
main: == 20230412204201 RemoveServerlessDomainClusterKnativeFk: reverted (0.0167s) ==
main: == 20230412204143 RemoveServerlessDomainClusterPagesFk: reverting =============
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE serverless_domain_cluster ADD CONSTRAINT fk_rails_c09009dee1 FOREIGN KEY (pages_domain_id) REFERENCES pages_domains (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0009s
main: -- execute("ALTER TABLE serverless_domain_cluster VALIDATE CONSTRAINT fk_rails_c09009dee1;")
main: -> 0.0013s
main: == 20230412204143 RemoveServerlessDomainClusterPagesFk: reverted (0.0178s) ====
main: == 20230412203234 RemoveClustersApplicationsJupyterOauthFk: reverting =========
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE clusters_applications_jupyter ADD CONSTRAINT fk_rails_331f0aff78 FOREIGN KEY (oauth_application_id) REFERENCES oauth_applications (id) ON DELETE SET NULL NOT VALID;")
main: -> 0.0009s
main: -- execute("ALTER TABLE clusters_applications_jupyter VALIDATE CONSTRAINT fk_rails_331f0aff78;")
main: -> 0.0011s
main: == 20230412203234 RemoveClustersApplicationsJupyterOauthFk: reverted (0.0167s)
main: == 20230412201642 RemoveClustersApplicationsRunnersFk: reverting ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE clusters_applications_runners ADD CONSTRAINT fk_rails_22388594e9 FOREIGN KEY (cluster_id) REFERENCES clusters (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0006s
main: -- execute("ALTER TABLE clusters_applications_runners VALIDATE CONSTRAINT fk_rails_22388594e9;")
main: -> 0.0009s
main: == 20230412201642 RemoveClustersApplicationsRunnersFk: reverted (0.0147s) =====
main: == 20230412201632 RemoveClustersApplicationsPrometheusFk: reverting ===========
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE clusters_applications_prometheus ADD CONSTRAINT fk_rails_557e773639 FOREIGN KEY (cluster_id) REFERENCES clusters (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0006s
main: -- execute("ALTER TABLE clusters_applications_prometheus VALIDATE CONSTRAINT fk_rails_557e773639;")
main: -> 0.0007s
main: == 20230412201632 RemoveClustersApplicationsPrometheusFk: reverted (0.0160s) ==
main: == 20230412201621 RemoveClustersApplicationsKnativeFk: reverting ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE clusters_applications_knative ADD CONSTRAINT fk_rails_54fc91e0a0 FOREIGN KEY (cluster_id) REFERENCES clusters (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0007s
main: -- execute("ALTER TABLE clusters_applications_knative VALIDATE CONSTRAINT fk_rails_54fc91e0a0;")
main: -> 0.0007s
main: == 20230412201621 RemoveClustersApplicationsKnativeFk: reverted (0.0158s) =====
main: == 20230412201611 RemoveClustersApplicationsJupyterFk: reverting ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE clusters_applications_jupyter ADD CONSTRAINT fk_rails_17df21c98c FOREIGN KEY (cluster_id) REFERENCES clusters (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0007s
main: -- execute("ALTER TABLE clusters_applications_jupyter VALIDATE CONSTRAINT fk_rails_17df21c98c;")
main: -> 0.0007s
main: == 20230412201611 RemoveClustersApplicationsJupyterFk: reverted (0.0158s) =====
main: == 20230412201600 RemoveClustersApplicationsIngressFk: reverting ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE clusters_applications_ingress ADD CONSTRAINT fk_rails_753a7b41c1 FOREIGN KEY (cluster_id) REFERENCES clusters (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0006s
main: -- execute("ALTER TABLE clusters_applications_ingress VALIDATE CONSTRAINT fk_rails_753a7b41c1;")
main: -> 0.0007s
main: == 20230412201600 RemoveClustersApplicationsIngressFk: reverted (0.0153s) =====
main: == 20230412201549 RemoveClustersApplicationsHelmFk: reverting =================
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE clusters_applications_helm ADD CONSTRAINT fk_rails_3e2b1c06bc FOREIGN KEY (cluster_id) REFERENCES clusters (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0048s
main: -- execute("ALTER TABLE clusters_applications_helm VALIDATE CONSTRAINT fk_rails_3e2b1c06bc;")
main: -> 0.0067s
main: == 20230412201549 RemoveClustersApplicationsHelmFk: reverted (0.0723s) ========
main: == 20230412201539 RemoveClustersApplicationsCrossplaneFk: reverting ===========
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE clusters_applications_crossplane ADD CONSTRAINT fk_rails_87186702df FOREIGN KEY (cluster_id) REFERENCES clusters (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0057s
main: -- execute("ALTER TABLE clusters_applications_crossplane VALIDATE CONSTRAINT fk_rails_87186702df;")
main: -> 0.0048s
main: == 20230412201539 RemoveClustersApplicationsCrossplaneFk: reverted (0.0800s) ==
main: == 20230412201528 RemoveClustersApplicationsCiliumFk: reverting ===============
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE clusters_applications_cilium ADD CONSTRAINT fk_rails_59dc12eea6 FOREIGN KEY (cluster_id) REFERENCES clusters (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0022s
main: -- execute("ALTER TABLE clusters_applications_cilium VALIDATE CONSTRAINT fk_rails_59dc12eea6;")
main: -> 0.0008s
main: == 20230412201528 RemoveClustersApplicationsCiliumFk: reverted (0.1182s) ======
main: == 20230412201517 RemoveClustersApplicationsCertManagersFk: reverting =========
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE clusters_applications_cert_managers ADD CONSTRAINT fk_rails_9e4f2cb4b2 FOREIGN KEY (cluster_id) REFERENCES clusters (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0008s
main: -- execute("ALTER TABLE clusters_applications_cert_managers VALIDATE CONSTRAINT fk_rails_9e4f2cb4b2;")
main: -> 0.0007s
main: == 20230412201517 RemoveClustersApplicationsCertManagersFk: reverted (0.0173s)
main: == [advisory_lock_connection] object_id: 273880, pg_backend_pid: 29766
Edited by Hunter Stewart