Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip schema.rb when schema_format is set to :sql #113

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to break db:migrate in recent versions of Rails:

NoMethodError: undefined method `schema_format' for ActiveRecord::Base:Class (NoMethodError)

It looks like ActiveRecord::Base.schema_format after Rails v3.2.13 was deprecated and removed. After that version it's just ActiveRecord.schema_format instead.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch @jasonopslevel! fixed in #118 and released in v1.1.1 🤞


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