Use the command line switch option -e to input the query and > to redirect the output to a file:
Best results in other decks
Performing COUNT(*) on large tables is slow. Sometimes you don’t need the exact number once results exceed a certain...
In Rails 8 the behavior of the rails db:migrate command has changed for fresh databases (see PR #52830).