Repository: rails/rails
File: activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb (Ruby)

Code before:
          end
        end

        def check_constraint_for(table_name, **options)
          return unless supports_check_constraints?
          chk_name = check_constraint_name(table_name, **options)
          check_constraints(table_name).detect { |chk| chk.defined_for?(name: chk_name, **options) }
        end

        def check_constraint_for!(table_name, expression: nil, **options)
          check_constraint_for(table_name, expression: expression, **options) ||
            raise(ArgumentError, "Table '#{table_name}' has no check constraint for #{expression || options}")
        end

        def validate_index_length!(table_name, new_name, internal = false)
          if new_name.length > index_name_length
            raise ArgumentError, <<~MSG.squish
              Index name '#{new_name}' on table '#{table_name}' is too long (#{new_name.length} characters); the limit
              is #{index_name_length} characters
            MSG
          end
        end

        def validate_table_length!(table_name)
          if table_name.length > table_name_length
            raise ArgumentError, <<~MSG.squish
              Table name '#{table_name}' is too long (#{table_name.length} characters); the limit is #{table_name_length} characters
            MSG
          end
        end

        def extract_new_default_value(default_or_changes)
          if default_or_changes.is_a?(Hash) && default_or_changes.has_key?(:from) && default_or_changes.has_key?(:to)
            default_or_changes[:to]
          else
            default_or_changes
          end
        end
        alias :extract_new_comment_value :extract_new_default_value

        def can_remove_index_by_name?(column_name, options)
          column_name.nil? && options.key?(:name) && options.except(:name, :algorithm).empty?
        end

        def reference_name_for_table(table_name)
          table_name.to_s.singularize
        end

        def add_column_for_alter(table_name, column_name, type, **options)
          td = create_table_definition(table_name)
          cd = td.new_column_definition(column_name, type, **options)

Review comment (suggestion):
I don’t think squish is needed here, since the message is already one line and <<~ should be enough by itself. That said, if you want to keep it consistent with validate_index_length! or anticipate that the message might grow longer in the future, leaving it as is would be totally fine.
```suggestion
            raise ArgumentError, <<~MSG
```

Code after:
          end
        end

        def check_constraint_for(table_name, **options)
          return unless supports_check_constraints?
          chk_name = check_constraint_name(table_name, **options)
          check_constraints(table_name).detect { |chk| chk.defined_for?(name: chk_name, **options) }
        end

        def check_constraint_for!(table_name, expression: nil, **options)
          check_constraint_for(table_name, expression: expression, **options) ||
            raise(ArgumentError, "Table '#{table_name}' has no check constraint for #{expression || options}")
        end

        def validate_index_length!(table_name, new_name, internal = false)
          if new_name.length > index_name_length
            raise ArgumentError, <<~MSG.squish
              Index name '#{new_name}' on table '#{table_name}' is too long (#{new_name.length} characters); the limit
              is #{index_name_length} characters
            MSG
          end
        end

        def validate_table_length!(table_name)
          if table_name.length > table_name_length
            raise ArgumentError, <<~MSG.squish
              Table name '#{table_name}' is too long (#{table_name.length} characters); the limit is
              #{table_name_length} characters
            MSG
          end
        end

        def extract_new_default_value(default_or_changes)
          if default_or_changes.is_a?(Hash) && default_or_changes.has_key?(:from) && default_or_changes.has_key?(:to)
            default_or_changes[:to]
          else
            default_or_changes
          end
        end
        alias :extract_new_comment_value :extract_new_default_value

        def can_remove_index_by_name?(column_name, options)
          column_name.nil? && options.key?(:name) && options.except(:name, :algorithm).empty?
        end

        def reference_name_for_table(table_name)
          table_name.to_s.singularize
        end

        def add_column_for_alter(table_name, column_name, type, **options)
          td = create_table_definition(table_name)