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

Version Path
six-updater-web-0.24.15 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.14 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.13 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.12 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.11 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.10 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.9 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.8 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.7 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.6 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.5 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.4 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.3 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.2 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.1 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.24.0 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.23.7 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.23.6 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.23.5 lib/six-updater-web/lib/tasks/fixtures.rake
six-updater-web-0.23.4 lib/six-updater-web/lib/tasks/fixtures.rake