Skip to content

nirds/timecapsule

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

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

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

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages