Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

timecapsule

Gem Version Build Status CodeClimate

Gem for importing and exporting ActiveRecord data as CSV files. Great for creating seed data from data entered through your app's UI or the console.

Install:

Add it to your Gemfile

gem 'timecapsule'

Or install it to your system:

$ gem install timecapsule

For Rails <3.0 use:

$ gem install --version '= 1.0.0' timecapsule

Usage:

As a Rake Task

  • Export all models as individual CSV files. If your database is huge, this could take a while.
$ rake timecapsule:all
  • Export a model from your app to a CSV file. User model as an example.
$ rake timecapsule:users
  • To view all models that timecapsule can export:
$ rake -T

For Rails Console

  • Export a model from your app to a csv file via rails console.
Timecapsule.export_model(User)
  • Import a model from the csv file:
Timecapsule.import_model(User)
  • To specify a different import or export directory, besides the default db/seed_data, open the automatically generated config/timecapsule.yml file and change the export directory.
  • To import all the csv files in your import directory call the import method:
Timecapsule.import
  • If the order of import matters for your models, you can specify the order at export time:
Timecapsule.export_model(User, 1)
Timecapsule.export_model(Post, 2)
  • Remember that if you want to maintain relationships between import/export you must reset the primary key sequence (id) for each of the tables for your models. Or drop and re-create your database.

Copyright (c) 2011-present MIT

Authors: Renée Hendricksen, Kerri Miller, Risa Batta

About

gem for importing and exporting ActiveRecord data. Great for creating seed data from data entered through your app's ui or the console

Resources

License

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages

You can’t perform that action at this time.