Hello,
Is it advisable to use the build-test-data plugin to load the bootstrap (seed/initial) data for an application. The plugin tutorial is excellent at http://bitbucket.org/tednaleid/grails-test-data/wiki/Home , but only mention about loading test data. There is a section about TestDataConfig , which allows to set default data. But is it a viable option if the data needs to persist in a larger scale, with complex relations.\
thanks.
views:
96answers:
2It depends on your data. If you only need a few things like administrator account info, list of categories, etc it should work fine. I'd use it if you’re testing your app with the initial seed data and everything works fine. For large or complex data imports I'd use a gant script to create and save for all the domain objects. For example I'm working on a project that requires me to move data out of a legacy database into a grails application. For this I run a script that uses JDBC calls to get all the old data out of the legacy database. I then create and save new domain objects based off this data. For an example of how to run a script that has access to the entire Grails context including Gorm see this
Testing data is the primary focus of the plugin, but I use it for all kinds of data loading situations, including bootstrapping data into a new system.
The only thing you need to be aware of is that the plugin, by design, will fill in any holes in required data that you don't supply. This means that you should specify everything that you actually want specific values on (or putting it in the TestDataConfig that you mention). If you don't give build-test-data a value, it'll make something up and that might be something that you don't want.
The newly added functionality around buildLazy makes it even easier to hook into an existing graph of objects that you might have in a BootStrap configuration.