diff --git a/db/post_migrate/20250904012006_prepare_tmp_idx_events_where_project_target_type_missing.rb b/db/post_migrate/20250904012006_prepare_tmp_idx_events_where_project_target_type_missing.rb new file mode 100644 index 0000000000000000000000000000000000000000..7a4a70f28129f2cd381e617c8f431d14d9e1bf97 --- /dev/null +++ b/db/post_migrate/20250904012006_prepare_tmp_idx_events_where_project_target_type_missing.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class PrepareTmpIdxEventsWhereProjectTargetTypeMissing < Gitlab::Database::Migration[2.3] + milestone '18.4' + + INDEX_NAME = :tmp_idx_events_where_project_target_type_missing + PROJECT_ACTIONS = [1, 5, 8, 9, 11].freeze # Defined in `/app/models/event.rb` + + def up + # rubocop:disable Migration/PreventIndexCreation -- temporary index for https://gitlab.com/gitlab-org/gitlab/-/issues/565788 + prepare_async_index( + :events, :id, + where: "target_type IS NULL AND action IN (#{PROJECT_ACTIONS.join(',')}) AND project_id IS NOT NULL", + name: INDEX_NAME + ) + # rubocop:enable Migration/PreventIndexCreation + end + + def down + unprepare_async_index_by_name :events, INDEX_NAME + end +end diff --git a/db/schema_migrations/20250904012006 b/db/schema_migrations/20250904012006 new file mode 100644 index 0000000000000000000000000000000000000000..fb35178dc89edf120033aa71399be75642c63811 --- /dev/null +++ b/db/schema_migrations/20250904012006 @@ -0,0 +1 @@ +3894e3e2c419f341ea7e58cffbac542fcf6cd930b954d0230041da412e8000ad \ No newline at end of file