![](/style/images/good.png)
![](/style/images/bad.png)
Rails deprecates `db:structure:load` and `db:structure:dump` tasks
source link: https://blog.saeloun.com/2020/09/30/rails-deprecates-db-structure-commands
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 has
deprecated
db:structure:load
and db:structure:dump
tasks.
Before
config.active_record.schema_format
controls the format for dumping the database schema to a file.
:ruby
(default) and :sql
are the valid options for this config.
Running rails db:schema:{dump,load}
will dump or load db/schema.rb file
and
rails db:structure:{dump,load}
will dump or load db/structure.sql file,
regardless of value specified for config.active_record.schema_format
.
After
Both the commands,
rails db:schema:{dump,load}
and
rails db:structure:{dump,load}
will run
rails db:schema:{dump,load}
depending on the value specified for config.active_record.schema_format
.
So running, rails db:schema:dump
or rails db:structure:dump
will dump db/schema.rb
file.
If we specify :sql
as the value for config.active_record.schema_format
,
running rails db:schema:dump
or rails db:structure:dump
will dump db/stucture.sql
file.
Running rails db:structure:{dump,load}
will result in a deprecation warning,
as these commands will be removed in Rails 6.2:
DEPRECATION WARNING: Using `bin/rails db:structure:load` is deprecated and will be removed in Rails 6.2.
Configure the format using `config.active_record.schema_format = :sql` to use `structure.sql`
and
run `bin/rails db:schema:load` instead
Note: config.active_support.deprecation = :stderr
has to be set for above deprecation message to show up.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK