Commit edf530f5 authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch 'initialize-sync_partitions' into 'master'

Move database partitioning code from initializers to module for reusing

See merge request gitlab-org/gitlab!74107
parents 0397b7e9 72aab740
......@@ -35,8 +35,4 @@ unless Gitlab.jh?
])
end
begin
Gitlab::Database::Partitioning.sync_partitions unless ENV['DISABLE_POSTGRES_PARTITION_CREATION_ON_STARTUP']
rescue ActiveRecord::ActiveRecordError, PG::Error
# ignore - happens when Rake tasks yet have to create a database, e.g. for testing
end
Gitlab::Database::Partitioning.sync_partitions_ignore_db_error
......@@ -31,6 +31,12 @@ module Gitlab
registered_tables.merge(tables)
end
def sync_partitions_ignore_db_error
sync_partitions unless ENV['DISABLE_POSTGRES_PARTITION_CREATION_ON_STARTUP']
rescue ActiveRecord::ActiveRecordError, PG::Error
# ignore - happens when Rake tasks yet have to create a database, e.g. for testing
end
def sync_partitions(models_to_sync = registered_for_sync)
Gitlab::AppLogger.info(message: 'Syncing dynamic postgres partitions')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment