2

When working on a large and complex rails app I find it difficult to locate and work with specific columns in the database admin tools as the columns (there are well over 100 of them on some models) are displayed in chronological order based on they were created within the app.

Does anyone know of a scalable way to order columns alphabetically in the schema and have any newly created columns automatically slot into their correct position?

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
Jamie Buchanan
  • 3,868
  • 4
  • 22
  • 24
  • There is no way to do this in PostgreSQL without a dump/edit schema/restore of the table. This is by design, so there is no "but what if I..." to work around it. – Matthew Wood Jan 09 '13 at 18:09
  • mysql provides the ability to reorder database columns: http://stackoverflow.com/questions/4095481/easy-way-to-re-order-columns i have no idea how this has an impact on the running system, but i guess it will lock the table for some time. – phoet Jan 09 '13 at 15:26
  • I found the Schema Plus gem https://github.com/lomba/schema_plus which looks like it orders tables alphabetically when doing a dump, but not columns. This strategy would not be useable on production either. I'll keep looking. – Jamie Buchanan Jan 14 '13 at 13:23

0 Answers0