shutyaev
shutyaev

Reputation: 287

java library to maintain database structure

My application is always developing, so occasionally - when the version upgrades - some tables need to be created/altered/deleted, some data modified, etc. Generally some sql code needs to be executed.

Is there a Java library that can be used to keep my database structure up to date (by analyzing something like "db structure version" information and executing custom sql to code to update from one version to another)?

Also it would be great to have some basic actions (like add/remove column) ready to use with minimal configuration, ie name/type and no sql code.

Upvotes: 11

Views: 3039

Answers (6)

gaboroncancio
gaboroncancio

Reputation: 900

You can also check Flyway (400 questions tagged on SOW) or mybatis (1049 questions tagged). To add to the comparison the other options mentioned: Liquibase (663 questions tagged) and DBDeploy (24 questions tagged).

Another resource that you can find useful is the feature comparison in the Flyway website (There are other related projects mentioned there).

Upvotes: 1

Vineet Reynolds
Vineet Reynolds

Reputation: 76709

Try DBDeploy. Although I haven't used it in the past, it sounds like this project would help in your case. DBDeploy is a database refactoring manager that:

"Automates the process of establishing which database refactorings need to be run against a specific database in order to migrate it to a particular build."

It is known to integrate with both Ant and Maven.

Upvotes: 3

Tomasz Blachowicz
Tomasz Blachowicz

Reputation: 5843

Try Liquibase.

Liquibase is an open source (Apache 2.0 Licensed), database-independent library for tracking, managing and applying database changes. It is built on a simple premise: All database changes are stored in a human readable yet trackable form and checked into source control.

Supported features:

  • Extensibility
  • Merging changes from multiple developers
  • Code branches
  • Multiple Databases
  • Managing production data as well as various test datasets
  • Cluster-safe database upgrades
  • Automated updates or generation of SQL scripts that can be approved and applied by a DBA
  • Update rollbacks
  • Database ”diff“s
  • Generating starting change logs from existing databases
  • Generating database change documentation

Upvotes: 3

user7094
user7094

Reputation:

We use a piece of software called Liquibase for this. It's very flexible and you can set it up pretty much however you want it. We have it integrated with Maven so our database is always up to date.

Upvotes: 2

Waldheinz
Waldheinz

Reputation: 10487

Most ORM mappers have logic to do schema upgrades for you, I have successfully used Hibernate which gets at least the basic stuff right automatically.

Upvotes: 0

Thor
Thor

Reputation: 6656

You should take a look into OR Mapping libraries, e.g. Hibernate

Upvotes: 0

Related Questions