Skip to content
  • eileencodes's avatar
    095f1bfa
    Refactor schema migration on connection · 095f1bfa
    eileencodes authored
    This method was jumping through extra hoops to find the name of the
    class the connection is stored on when we can get it from the connection
    itself. Since we already have the connection we don't need to loop through the
    pools.
    
    In addition, this was using the wrong class name. The class name for the
    schema migration should come from the connection owner class, not from
    the `db_config.name`. In this case, `db_config.name` is the name of the
    configuration in the database.yml. Rails uses the class name to lookup
    connections, not the db config name, so we should be consistent here.
    
    While working on this I noticed that we were generating an extra schema
    migration class for `ActiveRecord::Base`. Since `ActiveRecord::Base` can
    and should use the default and we don't want to create a new one for
    single db applications, we should skip creating this if the spec name is
    `ActiveRecord::Base`. I added an additional test that ensures the class
    generation is correct.
    095f1bfa
    Refactor schema migration on connection
    eileencodes authored
    This method was jumping through extra hoops to find the name of the
    class the connection is stored on when we can get it from the connection
    itself. Since we already have the connection we don't need to loop through the
    pools.
    
    In addition, this was using the wrong class name. The class name for the
    schema migration should come from the connection owner class, not from
    the `db_config.name`. In this case, `db_config.name` is the name of the
    configuration in the database.yml. Rails uses the class name to lookup
    connections, not the db config name, so we should be consistent here.
    
    While working on this I noticed that we were generating an extra schema
    migration class for `ActiveRecord::Base`. Since `ActiveRecord::Base` can
    and should use the default and we don't want to create a new one for
    single db applications, we should skip creating this if the spec name is
    `ActiveRecord::Base`. I added an additional test that ensures the class
    generation is correct.
Loading