Skip to content

Instantly share code, notes, and snippets.

@dpaluy
Created December 28, 2024 23:47
Show Gist options
  • Select an option

  • Save dpaluy/316ffbe100308e0e8c93f4429b7f6c9b to your computer and use it in GitHub Desktop.

Select an option

Save dpaluy/316ffbe100308e0e8c93f4429b7f6c9b to your computer and use it in GitHub Desktop.
Always keep the order of schema.rb
task :'db:schema:dump' => :'db:alphabetize_columns'
task :'db:alphabetize_columns' do
class << ActiveRecord::Base.connection
alias_method :old_columns, :columns unless self.instance_methods.include?("old_columns")
def columns(*args)
old_columns(*args).sort_by(&:name)
end
end
end
@dpaluy
Copy link
Author

dpaluy commented Dec 28, 2024

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