hobo:fixtures:dump breaks against non-mysql rdbmses
Reported by Brandon Valentine | July 2nd, 2008 @ 10:05 PM
In my case, SQLite, but it would break against Postgres as well. It uses the 'show tables' command which is MySQL specific. Better to use another method to iterate over the tables. Here's a rake recipe I'm using (as db:fixtures:dump):
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"]
ActiveRecord::Base.establish_connection(:development)
(ActiveRecord::Base.connection.tables - skip_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
end
end
This came from here. Please consider making this rake task database agnostic.
Thanks,
Brandon
Comments and changes to this ticket
-
Tom Locke July 29th, 2008 @ 10:13 AM
- State changed from new to resolved
I'm removing this because
- It's out of date now that we have foxy-fixtures
- Fixtures are lame anyway :)
Removed in 808f5ce40937e0704378c7a684de9d7a5524bb93
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป