Re: [Rails-core] Schema.rb table and column order
On Mon, Jan 19, 2015 at 3:35 PM, Matt Jones al2o...@gmail.com wrote: On Jan 17, 2015, at 5:01 AM, vesan vesan2...@gmail.com wrote: When multiple people are working on a single Rails codebase and they add migrations with new columns (or tables) and run the migrations in different order there is a problem with schema.rb. After this every time migrations are run the columns swap places if the previous version of the schema.rb file has been commited by the other developer who did run the migrations in different order. Because of this the developers have to discard the lines where columns swap places to keep the source control clean. Could this be fixed by putting the tables and columns on schema.rb in alphabetical order? Or are people relying on the database's order of the tables and columns? It seems you could implement it by sticking `.sort_by(:name)` to https://github.com/rails/rails/blob/3f96b6973b82ad17e443dd1d21be05996fb6fbf0/activerecord/lib/active_record/schema_dumper.rb#L134 There’s not a ton of evidence that column order can affect performance, but there are definitely cases - MyISAM tables with many varchar columns, for instance, will take longer to retrieve columns that are later in a row: http://explainextended.com/2009/05/21/choosing-column-order/ (YMMV, I haven’t performed this experiment myself) If this is added, it should be something users can switch off. Agreed, and am personally -1 on this, as it removes information from the schema file. Instead, how about a task/tool that will update a developer's database to match the schema file? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Core group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
Re: [Rails-core] Schema.rb table and column order
On Jan 17, 2015, at 5:01 AM, vesan vesan2...@gmail.com wrote: When multiple people are working on a single Rails codebase and they add migrations with new columns (or tables) and run the migrations in different order there is a problem with schema.rb. After this every time migrations are run the columns swap places if the previous version of the schema.rb file has been commited by the other developer who did run the migrations in different order. Because of this the developers have to discard the lines where columns swap places to keep the source control clean. Could this be fixed by putting the tables and columns on schema.rb in alphabetical order? Or are people relying on the database's order of the tables and columns? It seems you could implement it by sticking `.sort_by(:name)` to https://github.com/rails/rails/blob/3f96b6973b82ad17e443dd1d21be05996fb6fbf0/activerecord/lib/active_record/schema_dumper.rb#L134 There’s not a ton of evidence that column order can affect performance, but there are definitely cases - MyISAM tables with many varchar columns, for instance, will take longer to retrieve columns that are later in a row: http://explainextended.com/2009/05/21/choosing-column-order/ (YMMV, I haven’t performed this experiment myself) If this is added, it should be something users can switch off. —Matt Jones -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Core group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout. signature.asc Description: Message signed with OpenPGP using GPGMail
Re: [Rails-core] Schema.rb table and column order
I'm not sure that would fix it entirely because there's other things that cause differences between two developers schema files being generated. I do agree that a fix for this issue here would have a big impact across the ecosystem. Generally what I do is simply not check-in the schema.rb file unless I have made field changes. This is preferred often, as it means you need to force yourself to examine your git commits carefully instead of just using git add . which I think is a good practice. On Jan 17, 2015, at 7:22 PM, Nicholas Firth-McCoy n...@nfm.id.au wrote: Great idea! Once schemas do get out of sync this crops every time a developer runs `db:migrate`, regardless of whether they're adding a migration. It's something I see pretty frequently. On Saturday, January 17, 2015 at 9:01:52 PM UTC+11, vesan wrote: When multiple people are working on a single Rails codebase and they add migrations with new columns (or tables) and run the migrations in different order there is a problem with schema.rb. After this every time migrations are run the columns swap places if the previous version of the schema.rb file has been commited by the other developer who did run the migrations in different order. Because of this the developers have to discard the lines where columns swap places to keep the source control clean. Could this be fixed by putting the tables and columns on schema.rb in alphabetical order? Or are people relying on the database's order of the tables and columns? It seems you could implement it by sticking `.sort_by(:name)` to https://github.com/rails/rails/blob/3f96b6973b82ad17e443dd1d21be05996fb6fbf0/activerecord/lib/active_record/schema_dumper.rb#L134 https://github.com/rails/rails/blob/3f96b6973b82ad17e443dd1d21be05996fb6fbf0/activerecord/lib/active_record/schema_dumper.rb#L134 – Vesa Vänskä ve...@vesavanska.com javascript: -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Core group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com mailto:rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com mailto:rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout. Jason Fleetwood-Boldt t...@datatravels.com http://www.jasonfleetwoodboldt.com/writing -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Core group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
[Rails-core] Schema.rb table and column order
When multiple people are working on a single Rails codebase and they add migrations with new columns (or tables) and run the migrations in different order there is a problem with schema.rb. After this every time migrations are run the columns swap places if the previous version of the schema.rb file has been commited by the other developer who did run the migrations in different order. Because of this the developers have to discard the lines where columns swap places to keep the source control clean. Could this be fixed by putting the tables and columns on schema.rb in alphabetical order? Or are people relying on the database's order of the tables and columns? It seems you could implement it by sticking `.sort_by(:name)` to https://github.com/rails/rails/blob/3f96b6973b82ad17e443dd1d21be05996fb6fbf0/activerecord/lib/active_record/schema_dumper.rb#L134 – Vesa Vänskä v...@vesavanska.com -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Core group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.