From a466556b80fb5d78a4b3f34d1ac9c2c5ed864ca0 Mon Sep 17 00:00:00 2001 From: Ko Nagase Date: Mon, 6 Jan 2025 23:28:29 +0900 Subject: [PATCH 09/12] Support configurable tables --- lib/tasks/extract_fixtures.rake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tasks/extract_fixtures.rake b/lib/tasks/extract_fixtures.rake index 6d3a4f65b..1ce183b06 100644 --- a/lib/tasks/extract_fixtures.rake +++ b/lib/tasks/extract_fixtures.rake @@ -37,6 +37,7 @@ end 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 || {} @@ -47,7 +48,8 @@ task :extract_fixtures => :environment do 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) -- 2.49.0