Issue #17197: Using required and index on ActiveRecord generator creates wrong migration

https://github.com/rails/rails/issues/17197