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