Skip to content

Commit

Permalink
only print safety_assured if strong migrations are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
claireannecotter committed Oct 29, 2024
1 parent 0a39421 commit ad51094
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/squasher/templates/init_schema.rb.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
class InitSchema < ActiveRecord::Migration<%= @config.migration_version %>
def up
return init_schema if strong_migrations_missing?
safety_assured { init_schema }
<%- if defined?(StrongMigrations).present? -%>
<%= " safety_assured { init_schema }" -%>
<%- else -%>
<%= " init_schema" -%>
<%- end -%>
end

def down
raise ActiveRecord::IrreversibleMigration, "The initial migration is not revertable"
end

private
def strong_migrations_missing?
gem_dependency = Gem::Dependency.new(StrongMigrations)
gem_dependency.matching_specs.first.present?
end


def init_schema
<%- each_schema_line do |line| -%>
<%- next if line.strip.empty? -%>
Expand Down

0 comments on commit ad51094

Please sign in to comment.