DBSteward maven plugin for deploying and upgrading your DBSteward-defined database
dbsteward/dbsteward-maven-plugin/master Build Status:
Here is a crash course for getting up and running building databases from DBSteward definitions as part of your maven build process.
- Check out the plugin code and mvn install the artifact to your m2 repo
[ nkiraly@bludgeon ~/dbsteward-maven-plugin ]
$ mvn install
- Define the plugin as a dependency in your pom.xml
<dependencies>
<dependency>
<groupId>org.dbsteward.maven</groupId>
<artifactId>dbsteward-maven-plugin</artifactId>
<version>1.4.1-SNAPSHOT</version>
</dependency>
</dependencies>
- Define the plugin as part of the build process in your pom.xml, specifying your DBSteward definition file inline in the plugin configuration:
<build>
<plugins>
<plugin>
<groupId>org.dbsteward.maven</groupId>
<artifactId>dbsteward-maven-plugin</artifactId>
<version>1.4.1-SNAPSHOT</version>
<configuration>
<sqlFormat>pgsql8</sqlFormat>
<definitionFile>example.xml</definitionFile>
<dbHost>localhost</dbHost>
<dbPort>5432</dbPort>
<dbName>someapp</dbName>
<dbUsername>dbsteward_ci</dbUsername>
<dbPassword>password1</dbPassword>
<dbBootstrap>postgres</dbBootstrap>
</configuration>
</plugin>
</plugins>
</build>
For more detailed examples, see example1
- Run the plugin sql-compile goal to build your database creation SQL file:
[ nkiraly@bludgeon ~/that-project-tho ]
$ mvn dbsteward:sql-compile
- Run the plugin db-create goal to build your database on the specified server:
[ nkiraly@bludgeon ~/that-project-tho ]
$ mvn dbsteward:db-create
Note: Steps 4 and 5 can be combined to compile and run your sql guaranteed fresh:
[ nkiraly@bludgeon ~/that-project-tho ]
$ mvn dbsteward:sql-compile dbsteward:db-create
Follow Steps 1 and 2 from Building a Database
- Define the plugin as part of the build process in your pom.xml, specifying your old (previous) and new (current) definition file in the plugin configuration:
<build>
<plugins>
<plugin>
<groupId>org.dbsteward.maven</groupId>
<artifactId>dbsteward-maven-plugin</artifactId>
<version>1.4.1-SNAPSHOT</version>
<configuration>
<sqlFormat>pgsql8</sqlFormat>
<oldDefinitionFile>example1.xml</oldDefinitionFile>
<newDefinitionFile>example2.xml</newDefinitionFile>
<dbHost>localhost</dbHost>
<dbPort>5432</dbPort>
<dbName>someapp</dbName>
<dbUsername>dbsteward_ci</dbUsername>
<dbPassword>password1</dbPassword>
</configuration>
</plugin>
</plugins>
</build>
For more detailed examples, see example2
- Run the plugin sql-diff goal to build your database upgrade SQL files:
[ nkiraly@bludgeon ~/that-project-tho ]
$ mvn dbsteward:sql-diff
- Run the plugin db-upgrade goal to upgrade your database on the specified server:
[ nkiraly@bludgeon ~/that-project-tho ]
$ mvn dbsteward:db-upgrade
Note: Steps 4 and 5 can be combined to compile and run your sql guaranteed fresh:
[ nkiraly@bludgeon ~/that-project-tho ]
$ mvn dbsteward:sql-diff dbsteward:db-upgrade
For examples of managing Slony replicated databases with dbsteward-maven-plugin, see example3 and example4