Repository: rails/rails
File: activerecord/lib/active_record/database_configurations/hash_config.rb (Ruby)

Code before:
      # will return `true` for the primary database and `false` for all other configs.
      def seeds?
        configuration_hash.fetch(:seeds, primary?)
      end

      # Determines whether to dump the schema/structure files and the filename that
      # should be used.
      #
      # If `configuration_hash[:schema_dump]` is set to `false` or `nil` the schema
      # will not be dumped.
      #
      # If the config option is set that will be used. Otherwise Rails will generate
      # the filename from the database config name.
      def schema_dump(format = schema_format)
        if configuration_hash.key?(:schema_dump)
          if config = configuration_hash[:schema_dump]
            config
          end
        elsif primary?
          schema_file_type(format)
        else
          "#{name}_#{schema_file_type(format)}"
        end
      end

      def schema_format
        configuration_hash[:schema_format]&.to_sym || ActiveRecord.schema_format
      end

      def database_tasks? # :nodoc:
        !replica? && !!configuration_hash.fetch(:database_tasks, true)
      end

      def use_metadata_table? # :nodoc:
        configuration_hash.fetch(:use_metadata_table, true)
      end

      private
        def schema_file_type(format)
          case format.to_sym
          when :ruby
            "schema.rb"
          when :sql
            "structure.sql"
          end
        end
    end
  end
end


Review comment (suggestion):
This should be no-doc, since we don't want apps calling `db_config.schema_format`.

```suggestion
      def schema_format # :nodoc:
```

Code after:
      # will return `true` for the primary database and `false` for all other configs.
      def seeds?
        configuration_hash.fetch(:seeds, primary?)
      end

      # Determines whether to dump the schema/structure files and the filename that
      # should be used.
      #
      # If `configuration_hash[:schema_dump]` is set to `false` or `nil` the schema
      # will not be dumped.
      #
      # If the config option is set that will be used. Otherwise Rails will generate
      # the filename from the database config name.
      def schema_dump(format = schema_format)
        if configuration_hash.key?(:schema_dump)
          if config = configuration_hash[:schema_dump]
            config
          end
        elsif primary?
          schema_file_type(format)
        else
          "#{name}_#{schema_file_type(format)}"
        end
      end

      def schema_format # :nodoc:
        format = configuration_hash[:schema_format]&.to_sym || ActiveRecord.schema_format
        raise "Invalid schema format" unless [ :ruby, :sql ].include? format
        format
      end

      def database_tasks? # :nodoc:
        !replica? && !!configuration_hash.fetch(:database_tasks, true)
      end

      def use_metadata_table? # :nodoc:
        configuration_hash.fetch(:use_metadata_table, true)
      end

      private
        def schema_file_type(format)
          case format.to_sym
          when :ruby
            "schema.rb"
          when :sql
            "structure.sql"
          end
        end
    end
  end
end