Skip to content

Commit

Permalink
Add db:structure:load_if_sql and db:schema:load_if_ruby back
Browse files Browse the repository at this point in the history
Those tasks are deprecated though, just to maintain backwards compartibility
and ask people to update their scripts.

Fixes #40658.
  • Loading branch information
rafaelfranca committed Nov 24, 2020
1 parent 90fa01b commit 18187a9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions activerecord/lib/active_record/railties/databases.rake
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 18187a9

Please sign in to comment.