Patch #41954 » 0009-Support-configurable-tables.patch
lib/tasks/extract_fixtures.rake | ||
---|---|---|
37 | 37 |
task :extract_fixtures => :environment do |
38 | 38 |
dir = ENV['DIR'] || './tmp/fixtures' |
39 | 39 |
time_offset = ENV['TIME_OFFSET'] || '' |
40 |
tables = ENV['TABLES']&.split(',') || [] |
|
40 | 41 |
skip_tables = ENV['SKIP_TABLES']&.split(',') || [] |
41 | 42 |
table_filters = ENV['TABLE_FILTERS']&.split(';')&.map {|tf| tf.split(":", 2)}&.to_h || {} |
42 | 43 | |
... | ... | |
47 | 48 |
skip_tables += ["schema_migrations", "ar_internal_metadata"] |
48 | 49 | |
49 | 50 |
ActiveRecord::Base.establish_connection |
50 |
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name| |
|
51 |
tables = tables.present? ? tables : ActiveRecord::Base.connection.tables |
|
52 |
(tables - skip_tables).each do |table_name| |
|
51 | 53 |
i = "000" |
52 | 54 |
File.open(File.join(dir, "#{table_name}.yml"), 'w') do |file| |
53 | 55 |
columns = ActiveRecord::Base.connection.columns(table_name) |