Hi again.
My project is based on JPA (hibernate) + spring + spring web flow + richfaces + jboss as + MySQL
I’m using liquibase (built from trunk reverted before rc5) for 2 purposes:
- db migration. I have couple of problems here, some of them discussed in previous post:
- some indexes for FK are not created (http://liquibase.org/forum/index.php?topic=675.0)
- diffdbtochangelog doesn’t work well with hibernate entities. Also it requires hibernate.cfg.xml file, but my project uses jpa (persistence.xml). Thats why I have an Ant target which uses the hbm2ddl to create a temporary schema from the entities and then I compare it with the current schema with diffdatabasetochangelog (works perfect)
- I had to modify the ant task so I can specify the id and the author of the changesets.
- DB backup and restore
The backup (dump) method uses code from ant the task GenerateChangeLogTask and diff.setDiffTypes(“data”);
Here I have 3 problems with the existing code.
- I need only one changeset for that changelog which I use as a dump file (currently there is a changeset for each table) and I need it to be alwaysRun=true.
Btw there is a bug in XMLChangeLogSerializer#createNode: should be
- if (changeSet.isAlwaysRun()) {
node.setAttribute(“runAlways”, “true”);
}
- I need to specify my own id of the changeset so I have to add to DiffResult:
- public void setIdRoot(String idRoot) {
this.idRoot = idRoot;
}
private String generateId() {
return idRoot + (diffData ? “” : “-” + changeNumber++);
}
- I have an issue with the generated changelog: I have a column which is ‘not null’ but on some entries it is empty. When I make the dump in generates :
To revert/restore data previously backed up with the described method above I do:
- delete all the data
- rollback to the changeset that the dump file is compatible with
- insert the data from the dump file
- migrate to the current schema (run the changeset that were rolled back on step 2)
For step 2 I need special method that rollbacks to a changeset with specified id wich is very similar to rollback(Date dateToRollBackTo, String contexts) except that I have to use my own ChangeSetFilter to defined which changesets should be rolled back. The problem is that I have to use some private members of class Liquibase like changeLogParameters. I tried to implement this method in my own class that extends Liquibase without using the private fields and it works since i don’t use different contexts.
So now I have to maintain my own version of liquibase which I don’t want to.
Is there any way to make liquibase API more friendly in my case?