Skip to content

DBSteward maven plugin for deploying and upgrading your DBSteward-defined database

License

Notifications You must be signed in to change notification settings

dbsteward/dbsteward-maven-plugin

Repository files navigation

dbsteward-maven-plugin

DBSteward maven plugin for deploying and upgrading your DBSteward-defined database

dbsteward/dbsteward-maven-plugin/master Build Status: dbsteward/dbsteward-maven-plugin/master Build Status

Usage Guide

Here is a crash course for getting up and running building databases from DBSteward definitions as part of your maven build process.

Building a Database

  1. Check out the plugin code and mvn install the artifact to your m2 repo
[ nkiraly@bludgeon ~/dbsteward-maven-plugin ]
$ mvn install
  1. 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>
  1. 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

  1. Run the plugin sql-compile goal to build your database creation SQL file:
[ nkiraly@bludgeon ~/that-project-tho ]
$ mvn dbsteward:sql-compile
  1. 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

Upgrading a Database

Follow Steps 1 and 2 from Building a Database

  1. 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

  1. Run the plugin sql-diff goal to build your database upgrade SQL files:
[ nkiraly@bludgeon ~/that-project-tho ]
$ mvn dbsteward:sql-diff
  1. 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

About

DBSteward maven plugin for deploying and upgrading your DBSteward-defined database

Resources

License

Stars

Watchers

Forks

Packages

No packages published