[Yves Senn & Matthew Draper]
The column check was embodied in the defaul index name.
If the :name option was used, the specified columns were not verified at all.
Given:
```
assert connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_yo_momma)
```
That index could have been defined on any field, not necessarily on `:foo_id`.
Follow-Up to https://github.com/rails/rails/pull/14348
Ensure that SQLCounter.clear_log is called after each test.
This is a step to prevent side effects when running tests. This will allow us to run them in random order.
Some adapter (SQLite3) need to perform renaming operations to support
the rails DDL. These rename prefixes operate with prefixes. When an
index name already uses up the full space provieded by
`index_name_length` these internal operations will fail. This patch
introduces `allowed_index_name_length` which respects the amount of
characters used for internal operations. It will always be <=
`index_name_length` and every adapter can define how many characters
need to be reserved.
This was there due historical reasons since
7dc45818dc to give the user the
possibility to create unique indexes passing "UNIQUE" as the third
argument
Our schema.rb is being generated with an `add_index` line similar to this:
add_index "foo", ["foo", "bar"], :name => "xxx", :length => {"foo"=>8, "bar=>nil}
This is the same as it was on Rails 3.1.3, however, now when that
schema.rb is evaluated, its generating bad SQL in MySQL:
Mysql::Error: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax
to use near '))' at line 1: CREATE UNIQUE INDEX
`xxx` ON `foo` (`foo`(8), `bar`())
This commit adds a check for nil on the length attribute to prevent the
empty parens from being output.