Sha256: 86d8de12aa88b3e2a553fd7397ce65b350ad204f509bdc5349dec59d4abc12d3
Contents?: true
Size: 1.05 KB
Versions: 96
Compression:
Stored size: 1.05 KB
Contents
namespace :db do namespace :fixtures do desc 'Create YAML test fixtures from data in an existing database. Defaults to development database. Set RAILS_ENV to override.' task :dump => :environment do sql = "SELECT * FROM %s" skip_tables = ["schema_info", "plugin_schema_migrations", "schema_migrations"] ActiveRecord::Base.establish_connection(RAILS_ENV) tables = ENV['TABLES'].split(',') if ENV['TABLES'] tables ||= (ActiveRecord::Base.connection.tables - skip_tables) tables.each do |table_name| i = "000" File.open("#{RAILS_ROOT}/test/fixtures/#{table_name}.yml", 'w') do |file| data = ActiveRecord::Base.connection.select_all(sql % table_name) file.write data.inject({}) { |hash, record| hash["#{table_name}_#{i.succ!}"] = record hash }.to_yaml end end end task :load_system => :environment do Six::Dbmanager.reload_system end task :load_data => :environment do Six::Dbmanager.reload_data end end end
Version data entries
96 entries across 96 versions & 1 rubygems