Sha256: 2687c62e0cd63177cae3a1bcc7aaed0d0faacc03fff727535b720dac205a98df
Contents?: true
Size: 987 Bytes
Versions: 1
Compression:
Stored size: 987 Bytes
Contents
require 'activerecord-clean-db-structure/clean_dump' Rake::Task['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.0 | lib/activerecord-clean-db-structure/tasks/clean_db_structure.rake |