0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Great for creating seed data from data entered through your app's UI or the console
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 2.3.5
>= 2.3.5
 Project Readme

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