I have a Liquibase migration that I manually run to load seed data from several CSV files into my database. I would like to run this migration each time I run grails run-app.
I think I have two questions in one:
- How to I integrate the
migrate
command into mygrails run-app? - How do I clear the
DATABASECHANGELOG
to allow me to run the same
migration over and over?
Or, is there a better way to load a lot of data into a DB from CSV files?
Question 1 – To integrate migrate command into run-app, you should listen for events thrown in run-app scripts. This is explained here, and a more complete article is here.
Question 2 – For clearing the database, perhaps you can write a migration that clears the db for you? The way I do it is use a little script I wrote that just drops and creates a db. It’s for MySQL: