But how to migrate to liquibase? I propose the following steps:
- Backup all you data! Really do it! E.g. with xstream. First try the following steps on a test db, of course!
- Generate your initial changelog with liquibase:
liquibase --defaultsFile=src/main/resources/liquibase.properties generateChangeLog
Check the xml file and if you need additional data into liquibase you could read how to do this here. Or if you like you can do this via:
<changeSet author="pk" id="1"> <customChange class="de.InitBean"/> </changeSet>
Then implement CustomSqlChange. Only the generateStatements method is important, where you add your sql statements. (Although it would be cool to use hibernate to create database independent statements. Anyone who did this?)
- Now drop all tables with squirell sql (right click all tables -> edit -> tables -> remove) and then execute in sql tab:
drop sequence HIBERNATE_SEQUENCE;
- Now you should be able to update with liquibase. First look at the generated sql statements:
liquibase --defaultsFile=src/main/resources/liquibase.properties updateSQL
liquibase --defaultsFile=src/main/resources/liquibase.properties update
liquibase should say sth. like: Migration successful
- Try executing your program or run tests. And make sure the tests do not overwrite or clear the db schema!
- After these steps migrating via liquibase should be possible.