Skip to content
  • Yorick Peterse's avatar
    Split Database::Connection into separate types · 9bb48c9b
    Yorick Peterse authored
    Gitlab::Database::Connection was a kitchen sink type of class: it had
    methods for obtaining database information (e.g. the database name),
    running WAL related queries, querying the status of transactions, and
    more.
    
    This commit splits this class into separate types. For example,
    reflection related methods are now located in
    Gitlab::Database::Reflection. Transaction related methods are moved into
    the Transactions module. The method to get a WAL diff has been moved
    into the LoadBalancer class.
    
    With this also changes the use of these methods. For example, instead of
    this:
    
        Gitlab::Database.main.cached_column_exists?(:users, :id)
    
    You now write this:
    
        Users.database.cached_column_exists?(:id)
    
    Apart from being shorter in many cases, it also decouples the code using
    these methods from the main database. This makes it easier to support
    multiple databases over time.
    9bb48c9b