Skip to content

Comments

Revert: Sort table columns by name when dumping schema#56842

Open
bert-mccutchen wants to merge 1 commit intorails:mainfrom
bert-mccutchen:revert-schema_dumper_sort_columns
Open

Revert: Sort table columns by name when dumping schema#56842
bert-mccutchen wants to merge 1 commit intorails:mainfrom
bert-mccutchen:revert-schema_dumper_sort_columns

Conversation

@bert-mccutchen
Copy link

Motivation / Background

This Pull Request has been created for the Rails core team to review reverting sorted schema columns.

This is based on the findings outlined in discussion on #55414 (comment).

Based on my findings, the original approach of sorting schema columns is not the appropriate solution to the problem the original developer was facing.

Detail

Additional information

N/A

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@bert-mccutchen bert-mccutchen changed the title Reverted: Sort table columns by name when dumping schema Revert: Sort table columns by name when dumping schema Feb 18, 2026
@pixeltrix
Copy link
Contributor

I agree with reverting the change to sorting the columns when dumping for the following reasons:

  1. What was an occasional issue with a developer's local database not matching the order of the production database is now a issue of every developer's local database not matching each other developer's local database as well as production. To avoid drift between developers' databases they'll need to recreate and reseed them, making migrations effectively a production only feature. This may make sense for AI agentic workflows where you are creating and seeding databases constantly when spinning up agents but it's not great for humans who may be maintaining local data for a feature they're working on and need to merge in the work of other developers.

  2. It breaks workflows where column order is significant such as loading bulk data from CSVs. For example we use PG::Connection#put_copy_data to load data updates from CSVs for both development and production environments and now have to put workarounds in to ensure correct ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants