diff options
Diffstat (limited to 'lib/gitlab/database/async_indexes/migration_helpers.rb')
-rw-r--r-- | lib/gitlab/database/async_indexes/migration_helpers.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/gitlab/database/async_indexes/migration_helpers.rb b/lib/gitlab/database/async_indexes/migration_helpers.rb index dff6376270a..2f990aba2fb 100644 --- a/lib/gitlab/database/async_indexes/migration_helpers.rb +++ b/lib/gitlab/database/async_indexes/migration_helpers.rb @@ -55,11 +55,14 @@ module Gitlab schema_creation = ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaCreation.new(ApplicationRecord.connection) definition = schema_creation.accept(create_index) - async_index = PostgresAsyncIndex.safe_find_or_create_by!(name: index_name) do |rec| + async_index = PostgresAsyncIndex.find_or_create_by!(name: index_name) do |rec| rec.table_name = table_name rec.definition = definition end + async_index.definition = definition + async_index.save! # No-op if definition is not changed + Gitlab::AppLogger.info( message: 'Prepared index for async creation', table_name: async_index.table_name, @@ -68,8 +71,6 @@ module Gitlab async_index end - private - def async_index_creation_available? ApplicationRecord.connection.table_exists?(:postgres_async_indexes) && Feature.enabled?(:database_async_index_creation, type: :ops) |