Sha256: bb00736d8daf371c300fcd8929d1b1ce6bfc8f36bff597e68ccf67cac28ef10f
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'activerecord-clean-db-structure/clean_dump' Rake::Task[ActiveRecord.version >= Gem::Version.new('6.1') ? 'db:schema:dump' : 'db:structure:dump'].enhance do filenames = [] filenames << ENV['DB_STRUCTURE'] if ENV.key?('DB_STRUCTURE') if ActiveRecord::VERSION::MAJOR >= 6 # Based on https://github.com/rails/rails/pull/36560/files databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |spec_name| Rails.application.config.paths['db'].each do |path| filenames << File.join(path, spec_name + '_structure.sql') end end end unless filenames.present? Rails.application.config.paths['db'].each do |path| filenames << File.join(path, 'structure.sql') end 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.4.1 | lib/activerecord-clean-db-structure/tasks/clean_db_structure.rake |