Rails migration is always inserting whitespaces or changing the ordering of columns in the schema
I built a gem to solve this problem.
It sorts columns, index names and foreign keys, removes excess whitespace and runs Rubocop for some formatting to unify the output of your schema.rb file.
https://github.com/jakeonrails/fix-db-schema-conflicts
After you add it to your Gemfile you just run rake db:migrate or rake db:schema:dump like normal.
Good news! Rails finally pushed out an update which solves exactly this. Starting from Rails v5.1.0, the default (and only option) is to remove any extra spaces between the columns.
I suspect that this error is caused by the different configuration of white spaces ('tab width' if you are using sublime).