1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add db:structure:load_if_sql and db:schema:load_if_ruby back

Those tasks are deprecated though, just to maintain backwards compartibility
and ask people to update their scripts.

Fixes #40658.
This commit is contained in:
Rafael Mendonça França 2020-11-24 22:09:41 +00:00
parent 90fa01b4c0
commit 18187a95dc
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948

View file

@ -455,6 +455,14 @@ db_namespace = namespace :db do
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(ActiveRecord::Base.schema_format, ENV["SCHEMA"])
end
task load_if_ruby: ["db:create", :environment] do
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Using `bin/rails db:schema:load_if_ruby` is deprecated and will be removed in Rails 6.2.
Configure the format using `config.active_record.schema_format = :ruby` to use `schema.rb` and run `bin/rails db:schema:load` instead.
MSG
db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby
end
namespace :dump do
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
desc "Creates a database schema file (either db/schema.rb or db/structure.sql, depending on `config.active_record.schema_format`) for #{name} database"
@ -529,6 +537,14 @@ db_namespace = namespace :db do
db_namespace["schema:load"].invoke
end
task load_if_sql: ["db:create", :environment] do
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Using `bin/rails db:structure:load_if_sql` 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.
MSG
db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :sql
end
namespace :dump do
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
desc "Dumps the #{name} database structure to db/structure.sql. Specify another file with SCHEMA=db/my_structure.sql"