Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think you're asking two questions here that are intertwined so if I'm to break it down:</p> <ul> <li>You want to get test data into and out of your DB quickly and fixtures aren't doing it for you.</li> <li>You've been burnt by a schema change and you want to make sure that whatever you do doesn't require eight iterations themed "fiddling with the test data...still" :)</li> </ul> <p>You've got a couple of alternatives here which I've hashed out below. Because you've mentioned Oracle I'm using Oracle technologies here but the same thing is true for other DB platforms (e.g. Postgresql):</p> <ol> <li>Rake tesks that call PL/SQL scripts to generate the data, nasty horrible evil idea, don't do it unless there's no other option. I did it on one project that needed to load in billions of rows for some infrastructure architecture tests. I still sulk about it.</li> <li>Get your DB into a dump format. For speedy binary dumps check out the exp/imp and data pump utilities. This will allow you quick setup and teardown of your DB. Certainly on a rails project I worked on we used rake tasks to exp/imp a database which had around 300k records in under a minute. Also check SQL<em>Loader which is the logical dump utility, as its logical its slower and requires you to have control scripts to help SQL</em>Loader understand the dumps. However, the benefit of the logical dump is that you can run transformation scripts over them to massage the data into the latest format. Sadly though just like fixtures all these tools are pretty sensitive to change in the schema.</li> <li>Use a plugin such as <a href="http://github.com/notahat/machinist/tree/master" rel="nofollow noreferrer">Machinist</a> or <a href="http://github.com/thoughtbot/factory_girl/tree/master" rel="nofollow noreferrer">Factory Girl</a> to make the generation of the data nicer. You still incur the penalty of using ActiveRecord to setup the DB but these fake object generators will help you stay close to you migrations and are a lot less hassle to maintain than fixtures.</li> <li>Combine approaches 2 and 3. What happens here is that you make some test data with say Machinst. You export that test data to a dump and then reload the dump during each test run. When the schema changes update the Machinist config and re-export.</li> </ol> <p>Hope that helps. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload