Skip to content
  • eileencodes's avatar
    3335a0e7
    Backport a portion of #38684 · 3335a0e7
    eileencodes authored
    In Rails 6.0 the connection specification name for the
    ActiveRecord::Base class is `primary`. In 6.1 we've changed it to be
    `ActiveRecord::Base` to match how other classes behave.
    
    Due to the way the schema migration table and connection to that table
    are handled in Active Record we need to generate classes on the
    connection so those connections are able to find the correct table.
    Applications don't create the table, Rails does, and the default schema
    migration class inherits directly from Active Record.
    
    Since the default connection in 6.0 is named `primary` we end up with a
    class name of `primary::SchemaMigration` which is not a valid constant
    name and causes problems with Zeitwerk.
    
    I realized however that I never backported #38684 to 6.0 which skips
    the creation of the class for `ActiveRecord::Base` since it can use the
    default. This should fix the issue for Zeitwrk since we're no longer
    creating a `primary::SchemaMigration` class. The other databases in a
    multi-db application won't have issues because they use their actual
    class name, therefore causing no issues for Zeitwerk since it follows
    the Active Model naming pattern.
    
    Ref: #36757
    3335a0e7
    Backport a portion of #38684
    eileencodes authored
    In Rails 6.0 the connection specification name for the
    ActiveRecord::Base class is `primary`. In 6.1 we've changed it to be
    `ActiveRecord::Base` to match how other classes behave.
    
    Due to the way the schema migration table and connection to that table
    are handled in Active Record we need to generate classes on the
    connection so those connections are able to find the correct table.
    Applications don't create the table, Rails does, and the default schema
    migration class inherits directly from Active Record.
    
    Since the default connection in 6.0 is named `primary` we end up with a
    class name of `primary::SchemaMigration` which is not a valid constant
    name and causes problems with Zeitwerk.
    
    I realized however that I never backported #38684 to 6.0 which skips
    the creation of the class for `ActiveRecord::Base` since it can use the
    default. This should fix the issue for Zeitwrk since we're no longer
    creating a `primary::SchemaMigration` class. The other databases in a
    multi-db application won't have issues because they use their actual
    class name, therefore causing no issues for Zeitwerk since it follows
    the Active Model naming pattern.
    
    Ref: #36757
Loading