Project

copydb

0.0
No commit activity in last 3 years
No release in over 3 years
Copydb is a gem that helps you to copy databases e.g. from a production database to your development database. During the process it is possible to define columns in tables in which the data should be exchanged for fake data. This can be interesting in a scenario where you want to run your development machine with production data, but privacy laws (such as in Germany) prohibit you to use real data.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 0.9.5
 Project Readme

CopyDb

CopyDb is a tool for exporting your database into a YAML format.

CopyDb can be configured to anonymize certain parts of the database so that you can work with production data without violating your local privacy laws.

Installation

Simply add it to your Gemfile and run the bundle ocmmand

gem 'copydb'

bundle install

Usage

Once you have included CopyDb into your Rails project, you will have two new rake tasks, rake db:copydb:dump and rake db:copydb:load

rake db:copydb:dump -> Dumps the content of the database to tmp/copydb_dumped_data.yml
rake db:copydb:load -> Loads the content of the database from tmp/copydb_dumped_data.yml

Please be aware that you have to have an empty database with in at least the same schema version as the database is in that you got the data from.

Anonymizing

While exporting the database, CopyDb can anonymize certain columns of your database. Upon exporting, CopyDb looks for {RAILS_ROOT}/config/copydb_anonymize.yml. The file is standard YML format, here is an example:

---
people:
- firstname: first_name
- middlename: name
- lastname: last_name
- nickname: name
- address: street_address
- city: city
- zip: zip
- phone: phone
- email: email
- description: lorem

After this example, here is an explanation:

---
{tablename}:
- {column_name}: {column_type}

Depending on your column_type, different data is generated. You can choose from the following types:

  • name: a generic name (e.g. Miguel Larson)
  • first_name: a random first name (e.g. Filiberto)
  • last_name: a random last name (e.g. Jacobs)
  • street_address: a complete street address (e.g. 53585 Harris Gardens)
  • city: a city name (e.g. Princesston)
  • zip: a zip code (e.g. 42358)
  • phone: a phone number (e.g. (084)491-6537 x964)
  • email: an e-mail address of a free-mailer (e.g. dave.koss@gmail.com)
  • date: the date 2011-11-11
  • lorem: a sentence with 20 words

Credits

Created by Christoph Eicke, thanks to Orion Henry and Adam Wiggins for YamlDb.