You can do something like string {n}
.
$ rails g migration AddNameToUsers name:string{30}
The generated migration file will be as follows
class AddNameToUsers < ActiveRecord::Migration[6.0]
def change
add_column :users, :name, :string, limit: 30
end
end
You can also use uniq and index, but note that I forget only limit
for some reason.