views:

217

answers:

1

Hello Experts !

Last week i read about liquibase quick start and all the related tutorials but i feel like i don't get the whole drift about using it for consecutive change in the database and i have some questions still opened.

i'm developing an application in netbeans using maven with 3 modules: dbunit module, service module and the webapp module.As you might have guessed dbunit does the database stuffs, the service is on top of it and the webapp uses the services.so the parent pom has the declaration of all groupids, artifactids and versions for all jars and plugins.

I manage to generate the changelog file from command line since the db is already existing and supposing i set up everything correctly using liquibase maven plugin :

question 1 : What will the liquibase goal be since right now i'm doing any database change right now?

Question 2 : If i want to add for example a new table to the database, will i add the this new changeSet to the same changelog file or i have to create a new changelog.xml file?

Question 3 : I believe when the dbunit runs it will run the changeset but is that necessary to add the plugin to th webapp module too (maybe to run the liquibase goal before deployment with cargo plugin) or the dbunit will take care of that?

Question 4 : What exactly subversion helps with keep the states of the changelog (assuming there is only one changelog refere to question 2)

thanks for reading this and for you help.

+3  A: 
  1. See http://www.liquibase.org/manual/maven

so you should bind your liquibase execution to a phase like

<phase>process-resources</phase>

But i use a spring executor, too. So everytime my app starts up, it starts a liquibase executor to execute missing changelogs in the database. It is nice, because when you are ready with your work and your tests, liquibase has updated your dev database but not your production database. But when you install your war and start your webapp, liquibase handles it automatically to bring your database to current state. So you don't have to remember doing some extra stuff before deploying your new version.

  1. Keep your changelog.xml with includes to changelog files like this

    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
    when you want a new table, add a changelog-0002.xml file and reference it in your master changelog.xml

  2. see answer 1. I would put in your webapp module too.

  3. You should have many changelog files. so this question is not applicable.

Janning
Thanks for the explanation, i became clearer in my mind.There is another thing i'm wondering about.In my project `Spring` uses `hibernate`.i dropped the tables of my database, put `hbm2ddl` to `validate` and add the `generated changelog` to the `master changelog`, it seems when the test cases run, they fail because they can't find the tables, i'm, wondering if there is another trick to that.Thanks for the reply again
black sensei
I think you should use hbm2ddl only for your initial changelog. I don't use hbm2ddl at all.
Janning