Populate data

Hello guys,

Let’s take a look below situations:

  • During development mode many times we run command “rake db:migrate VERSION=0” (so all data will be lost!)
  • Our rails application is ready to run and we give it someone to test it. (without data???)
  • Client wants that developer will test on his test data so both can understand it very well. (will developer enter data manually?)

In above all situations we want development data again(of course easily! ). How can we get it? There are some options for this given below:

Seeds is nice option but it will be boring to write all data and populator and faker gem will populate fake data not development data.

So now what to do?

Let’s introduce yaml_db!!!

It’s very easy to use.

  • Install yaml_db as a plugin or gem
  • If you want to give your development data to someone else then run command “rake db:data:dump”
  • This command will create one file named “data.yml” at RAILS_ROOT/db folder. This file contains your all development data.
  • Now if someone wants to use this file then user will put this file at above location and will run command “rake db:data:load”
  • So development database will populate with all data and that’s it!

Isn’t it simple then you thought?

About pulkitengg055
Hi I am Pancholi Pulkit.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: