Skip to content

Commit b982eef

Browse files
committed
Respect all structure.sql files
This is especially helpful when you're working with Rails Engines.
1 parent 92b9d71 commit b982eef

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/activerecord-clean-db-structure/tasks/clean_db_structure.rake

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ Rake::Task['db:structure:dump'].enhance do
55
end
66

77
task :clean_db_structure do
8-
filename = ENV['DB_STRUCTURE'] || File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir, 'structure.sql')
8+
filenames = ENV['DB_STRUCTURE']
9+
filenames ||= Rails.application.config.paths['db'].map do |path|
10+
File.join(path, 'structure.sql')
11+
end
912

10-
cleaner = ActiveRecordCleanDbStructure::CleanDump.new(File.read(filename))
11-
cleaner.run
12-
File.write(filename, cleaner.dump)
13+
filenames.each do |filename|
14+
cleaner = ActiveRecordCleanDbStructure::CleanDump.new(File.read(filename))
15+
cleaner.run
16+
File.write(filename, cleaner.dump)
17+
end
1318
end

0 commit comments

Comments
 (0)