Rails 7 adds support for setting the schema dump filepath in the database config
source link: https://blog.saeloun.com/2022/03/09/schema-dump-path-config
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Rails 7 adds support for setting the schema dump filepath in the database config
Mar 9, 2022 , by Swaathi Kakarla
1 minute read
One of the best features of Rails is its ORM, Active Record which makes it easy to interface with various database engines and even multiple databases themselves. However, not every database-specific task was available to these shards.
Only in Rails 6 was additional database-specific rake tasks
for multi-database users added.
This allowed tasks like schema dumps
to be run on individual databases via rails db:schema:dump:primary
and more.
Before
However, doing this will not allow users to specify the schema dump filepath. All dumps will write to the same location. This was quite troublesome as there was no easy way to quickly dump all shards without manual intervention.
After
Fortunately, this PR allows users to set the filename of the schema or structure dump in the database config.
production:
primary:
database: my_db
schema_dump: my_schema_dump_filename.rb
animals:
database: animals_db
schema_dump: false
The filename set in schema_dump
will be used by the application.
It is also possible to toggle dumping itself
by setting schema_dump
to false
.
Share this post!
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK