Skip to content

Commit

Permalink
Skip schema.rb when schema_format is set to :sql (#113)
Browse files Browse the repository at this point in the history
Fix for #93.
Behavior stays the same as it was for Rails 5 and above.
As it's said in the issue, we don't need to generate a `schema.rb` when
we don't have the setting `schema_format = :ruby`.
  • Loading branch information
davqasd authored Jan 2, 2024
1 parent f9aaa5a commit 16709ae
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/tasks/hair_trigger.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace :db do
namespace :schema do
desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
task :dump => :environment do
next unless ActiveRecord::Base.schema_format == :ruby

require 'active_record/schema_dumper'
filename = ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb"
ActiveRecord::SchemaDumper.previous_schema = File.exist?(filename) ? File.read(filename) : nil
Expand Down

0 comments on commit 16709ae

Please sign in to comment.