diff options
Diffstat (limited to 'db/post_migrate/20230726080827_add_issue_search_data_namespace_id_foreign_key.rb')
-rw-r--r-- | db/post_migrate/20230726080827_add_issue_search_data_namespace_id_foreign_key.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/db/post_migrate/20230726080827_add_issue_search_data_namespace_id_foreign_key.rb b/db/post_migrate/20230726080827_add_issue_search_data_namespace_id_foreign_key.rb new file mode 100644 index 00000000000..43b4db7d9b5 --- /dev/null +++ b/db/post_migrate/20230726080827_add_issue_search_data_namespace_id_foreign_key.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddIssueSearchDataNamespaceIdForeignKey < Gitlab::Database::Migration[2.1] + include Gitlab::Database::PartitioningMigrationHelpers + + disable_ddl_transaction! + + INDEX_NAME = 'index_issue_search_data_on_namespace_id' + + def up + add_concurrent_partitioned_index :issue_search_data, :namespace_id, name: INDEX_NAME + add_concurrent_partitioned_foreign_key :issue_search_data, :namespaces, + column: :namespace_id, + on_delete: :cascade + end + + def down + remove_foreign_key_if_exists :issue_search_data, column: :namespace_id + remove_concurrent_partitioned_index_by_name :issue_search_data, INDEX_NAME + end +end |