Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option not to line up column attributes in schema.rb #25675

Merged

Conversation

@TimPetricola
Copy link
Contributor

@TimPetricola TimPetricola commented Jul 4, 2016

Column arguments are lined up for a given table in schema.rb. It is intended as a feature but it can get confusing in git diffs where whitespace are often added for columns with no changes. This PR adds a ActiveRecord::SchemaDumper.standardized_argument_widths = false option to avoid that.

Let's say we have an address table with the following schema:

create_table "address", force: :cascade do |t|
  t.string "zipcode", limit: 5
end

Adding another column with a longer name would also change the line for zipcode:

-   t.string "zipcode", limit: 5
+   t.string "zipcode",           limit: 5
+   t.string "extra_information", limit: 255

And generated schema.rb would now be:

create_table "address", force: :cascade do |t|
  t.string "zipcode",           limit: 5
  t.string "extra_information", limit: 255
end

By setting ActiveRecord::SchemaDumper.standardized_argument_widths to false, we would have the following diff and schema instead:

+   t.string "extra_information", limit: 255
create_table "address", force: :cascade do |t|
  t.string "zipcode", limit: 5
  t.string "extra_information", limit: 255
end
@rails-bot
Copy link

@rails-bot rails-bot commented Jul 4, 2016

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @senny (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@TimPetricola TimPetricola force-pushed the TimPetricola:schema-no-standardized-column-widths branch 2 times, most recently Jul 4, 2016
@thewoolleyman
Copy link
Contributor

@thewoolleyman thewoolleyman commented Jul 5, 2016

+1, cleaner diffs are good.

@matthewd
Copy link
Member

@matthewd matthewd commented Jul 5, 2016

Can you expand on your reasoning behind keeping the type_length alignment?

@TimPetricola
Copy link
Contributor Author

@TimPetricola TimPetricola commented Jul 8, 2016

@matthewd My bad, it should have been there. I added a second ActiveRecord::SchemaDumper.standardized_type_widths option for this. It might be worth merging both though. What do you think?

@TimPetricola
Copy link
Contributor Author

@TimPetricola TimPetricola commented Jul 29, 2016

Any update on this one ? :)

@bdewater
Copy link
Contributor

@bdewater bdewater commented Aug 2, 2016

Personally I think this should be the default 😄 but since that is probably out of the question it should be documented (perhaps here?) and of course have a changelog entry.

@prathamesh-sonpatki
Copy link
Member

@prathamesh-sonpatki prathamesh-sonpatki commented Aug 15, 2016

I don't think the documentation should go to the migration guide because even without this patch we want to check in these files in the source control.

It should go the configuration guide here.

And we need changelog of course :)

@TimPetricola TimPetricola force-pushed the TimPetricola:schema-no-standardized-column-widths branch Aug 16, 2016
@TimPetricola
Copy link
Contributor Author

@TimPetricola TimPetricola commented Aug 16, 2016

Now with a changelog entry and some documentation in the configuration guide :) @prathamesh-sonpatki

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Aug 17, 2016

Could you squash your commits and rebase the branch?

@TimPetricola TimPetricola force-pushed the TimPetricola:schema-no-standardized-column-widths branch Aug 17, 2016
@TimPetricola TimPetricola force-pushed the TimPetricola:schema-no-standardized-column-widths branch to dde3bdf Aug 17, 2016
@TimPetricola
Copy link
Contributor Author

@TimPetricola TimPetricola commented Aug 17, 2016

@rafaelfranca Done. I get one error on Travis that seems unrelated though.

@maclover7
Copy link
Member

@maclover7 maclover7 commented Aug 17, 2016

@TimPetricola Restarted the random failing Action Cable test job. Should be good now, hopefully. :)

@TimPetricola
Copy link
Contributor Author

@TimPetricola TimPetricola commented Aug 17, 2016

Thanks @maclover7, it fixed it :)

@rafaelfranca rafaelfranca merged commit 84cc8fd into rails:master Aug 19, 2016
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
codeclimate Code Climate has skipped analysis of this commit.
Details
rafaelfranca added a commit that referenced this pull request Aug 19, 2016
…lumn-widths

Option not to line up column attributes in schema.rb
@dhh
Copy link
Member

@dhh dhh commented Aug 22, 2016

I'd prefer that we just make this the new style. No need to have this be configurable.

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Aug 22, 2016

Better yet. I just prepared a patch to remove the config and make it the default.

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Aug 22, 2016

Pushed in df84e98

javierm added a commit to javierm/consul that referenced this pull request Nov 19, 2019
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to javierm/consul that referenced this pull request Nov 19, 2019
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to javierm/consul that referenced this pull request Nov 19, 2019
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to javierm/consul that referenced this pull request Nov 19, 2019
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to javierm/consul that referenced this pull request Nov 19, 2019
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to javierm/consul that referenced this pull request Nov 19, 2019
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to javierm/consul that referenced this pull request Nov 19, 2019
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to javierm/consul that referenced this pull request Nov 19, 2019
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Nov 19, 2019
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Feb 28, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Mar 20, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 10, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 10, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 10, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 10, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 10, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 12, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 12, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 13, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 13, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 14, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to javierm/consul that referenced this pull request Apr 15, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 16, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 16, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 18, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 22, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 22, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 23, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
javierm added a commit to consul/consul that referenced this pull request Apr 23, 2020
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

rails/rails#25675

We're sorry for developers who are really concerned about code
alignment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet