Skip to content
Snippets Groups Projects

Introduce :gitlab_geo schema for Geo tracking DB

All threads resolved!
Compare and Show latest version
3 files
+ 14
8
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -34,12 +34,14 @@ def perform
@@ -34,12 +34,14 @@ def perform
# If two DBs are configured (Main, CI): minute 1 -> Main, minute 2 -> CI
# If two DBs are configured (Main, CI): minute 1 -> Main, minute 2 -> CI
def current_connection_name_and_base_model
def current_connection_name_and_base_model
minutes_since_epoch = Time.current.to_i / 60
minutes_since_epoch = Time.current.to_i / 60
connections_with_name = database_base_models.to_a # this will never be empty
connections_with_name = shared_database_base_models.to_a # this will never be empty
connections_with_name[minutes_since_epoch % connections_with_name.count]
connections_with_name[minutes_since_epoch % connections_with_name.count]
end
end
def database_base_models
def shared_database_base_models
Gitlab::Database.database_base_models.select { |db_name, _| db_name != 'geo' }
Gitlab::Database.schemas_to_base_models[:gitlab_shared].to_a.each_with_object({}) do |base_model, result|
 
result[Gitlab::Database.db_config_name(base_model.connection)] = base_model
 
end
end
end
end
end
end
end
Loading