Sha256: e2da98fd5d7f7f14b29e0e2b19604987ee32156a58ebcbe2c11f718e3f7ceed4

Contents?: true

Size: 748 Bytes

Versions: 1

Compression:

Stored size: 748 Bytes

Contents

require 'activerecord-clean-db-structure/clean_dump'

Rake::Task['db:structure:dump'].enhance do
  filenames = ENV['DB_STRUCTURE']

  if ActiveRecord::VERSION::MAJOR >= 6
    ActiveRecord::Tasks::DatabaseTasks.for_each do |spec_name|
      filenames ||= Rails.application.config.paths['db'].map do |path|
        File.join(path, spec_name + '_structure.sql')
      end
    end
  end

  filenames ||= Rails.application.config.paths['db'].map do |path|
    File.join(path, 'structure.sql')
  end

  filenames.each do |filename|
    cleaner = ActiveRecordCleanDbStructure::CleanDump.new(
      File.read(filename),
      **Rails.application.config.activerecord_clean_db_structure
    )
    cleaner.run
    File.write(filename, cleaner.dump)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-clean-db-structure-0.3.0 lib/activerecord-clean-db-structure/tasks/clean_db_structure.rake