[jbpm-commits] JBoss JBPM SVN: r5499 - in jbpm4/trunk/modules: db/scripts and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Aug 20 12:49:33 EDT 2009


Author: alex.guizar at jboss.com
Date: 2009-08-20 12:49:33 -0400 (Thu, 20 Aug 2009)
New Revision: 5499

Modified:
   jbpm4/trunk/modules/db/pom.xml
   jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml
   jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
Log:
[JBPM-1995] build script to calculate jBPM DB differences 
document feature and tie it to the "database" property

Modified: jbpm4/trunk/modules/db/pom.xml
===================================================================
--- jbpm4/trunk/modules/db/pom.xml	2009-08-20 14:10:20 UTC (rev 5498)
+++ jbpm4/trunk/modules/db/pom.xml	2009-08-20 16:49:33 UTC (rev 5499)
@@ -74,6 +74,7 @@
 									<tasks>
 										<property name="project.output.dir" value="${project.build.outputDirectory}"/>
 										<property name="previous.version.dir" value="${previous.version.directory}"/>
+                    <property name="database" value="${database}"/>
 										<ant antfile="scripts/antrun-upgrade.xml" target="upgrade-schema" inheritRefs="yes"/>
 									</tasks>
 								</configuration>

Modified: jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml
===================================================================
--- jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml	2009-08-20 14:10:20 UTC (rev 5498)
+++ jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml	2009-08-20 16:49:33 UTC (rev 5499)
@@ -1,93 +1,124 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project>
-	<!-- ============================================ -->
-	<!-- jBPM database schema                         -->
-	<!-- ============================================ -->
+  <!-- ============================================ -->
+  <!-- jBPM database schema                         -->
+  <!-- ============================================ -->
 
-	<target name="upgrade-schema">
-		<taskdef name="schemaupdate"
-		         classname="org.hibernate.tool.hbm2ddl.SchemaUpdateTask"
-		         classpathref="maven.compile.classpath" />
-		<taskdef name="schemaexport"
-		         classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
-		         classpathref="maven.compile.classpath" />
+  <target name="upgrade-schema"
+          depends="define-tasks, upgrade-hsqldb, upgrade-mysql, upgrade-postgresql, upgrade-oracle" />
 
-		<!-- HSQLDB -->
-		<java classname="org.hsqldb.Server"
-		      classpathref="maven.compile.classpath"
-		      fork="yes" spawn="yes">
-			<arg value="-port" />
-			<arg value="1701" />
-			<arg value="-database.0" />
-			<arg value="${previous.version.dir}/jbpmdb" />
-		</java>
-		<upgrade-ddl db="hsqldb" />
-		<sql url="${hsqldb.hibernate.connection.url}"
-		     driver="${hsqldb.hibernate.connection.driver_class}"
-		     classpathref="maven.compile.classpath"
-		     userid="${hsqldb.hibernate.connection.username}"
-		     password="${hsqldb.hibernate.connection.password}"
-		     autocommit="yes">
-			SHUTDOWN
-		</sql>
+  <target name="define-tasks">
+    <taskdef name="schemaupdate"
+             classname="org.hibernate.tool.hbm2ddl.SchemaUpdateTask"
+             classpathref="maven.compile.classpath" />
+    <taskdef name="schemaexport"
+             classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
+             classpathref="maven.compile.classpath" />
 
-		<!-- MySQL -->
-		<upgrade-ddl db="mysql" />
+    <condition property="database.is.hsqldb">
+      <equals arg1="${database}" arg2="hsqldb" />
+    </condition>
+    <condition property="database.is.mysql">
+      <equals arg1="${database}" arg2="mysql" />
+    </condition>
+    <condition property="database.is.postgresql">
+      <equals arg1="${database}" arg2="postgresql" />
+    </condition>
+    <condition property="database.is.oracle">
+      <equals arg1="${database}" arg2="oracle" />
+    </condition>
+  </target>
 
-		<!-- PostgreSQL -->
-		<upgrade-ddl db="postgresql" />
+  <target name="upgrade-hsqldb" if="database.is.hsqldb">
+    <java classname="org.hsqldb.Server"
+          classpathref="maven.compile.classpath"
+          fork="yes"
+          spawn="yes">
+      <arg value="-port" />
+      <arg value="1701" />
+      <arg value="-database.0" />
+      <arg value="${previous.version.dir}/jbpmdb" />
+    </java>
+    <waitfor>
+      <socket server="localhost" port="1701" />
+    </waitfor>
+    <upgrade-ddl db="hsqldb" />
+    <sql url="${hsqldb.hibernate.connection.url}"
+         driver="${hsqldb.hibernate.connection.driver_class}"
+         classpathref="maven.compile.classpath"
+         userid="${hsqldb.hibernate.connection.username}"
+         password="${hsqldb.hibernate.connection.password}"
+         autocommit="yes">
+      SHUTDOWN
+    </sql>
+  </target>
 
-		<!-- Oracle -->
-		<upgrade-ddl db="oracle" />
-	</target>
+  <target name="upgrade-mysql" if="database.is.mysql">
+    <upgrade-ddl db="mysql" />
+  </target>
 
-	<!-- ============================================ -->
-	<!-- Macro definitions                            -->
-	<!-- ============================================ -->
+  <target name="upgrade-postgresql" if="database.is.postgresql">
+    <upgrade-ddl db="postgresql" />
+  </target>
 
-	<macrodef name="upgrade-ddl">
-		<attribute name="db" />
+  <target name="upgrade-oracle" if="database.is.oracle">
+    <upgrade-ddl db="oracle" />
+  </target>
 
-		<sequential>
-			<echo>=====================</echo>
-			<echo>Upgrade DDL @{db}</echo>
+  <!-- ============================================ -->
+  <!-- Macro definitions                            -->
+  <!-- ============================================ -->
 
-			<!-- calculate the difference beetween the previous and the current create schemas -->
-			<exec command="diff" osfamily="unix" output="${previous.version.dir}/jbpm.@{db}.create.diff">
-				<arg value="-u" />
-				<arg file="${previous.version.dir}/jbpm.@{db}.create.sql" />
-				<arg file="${project.output.dir}/jbpm.@{db}.create.sql" />
-			</exec>
+  <macrodef name="upgrade-ddl">
+    <attribute name="db" />
 
-			<property name="@{db}.hibernate.cfg" value="src/main/config/@{db}.hibernate.cfg.xml" />
-			<property name="@{db}.hibernate.properties"
-			          value="${user.home}/.jbpm4/jdbc/@{db}.properties" />
-			<property file="${@{db}.hibernate.properties}" prefix="@{db}" />
-			<echo>driver... ${@{db}.hibernate.connection.driver_class}</echo>
-			<echo>url...... ${@{db}.hibernate.connection.url}</echo>
-			<echo>username. ${@{db}.hibernate.connection.username}</echo>
-			<echo>password. ${@{db}.hibernate.connection.password}</echo>
+    <sequential>
+      <echo>=====================</echo>
+      <echo>Upgrade DDL @{db}</echo>
 
-			<!-- drop current schema if exists -->
-			<schemaexport output="${project.output.dir}/jbpm.@{db}.drop.sql"
-			              config="${@{db}.hibernate.cfg}"
-			              properties="${@{db}.hibernate.properties}"
-			              drop="yes" quiet="yes" />
-			<!-- create previous version schema -->
-			<sql src="${previous.version.dir}/jbpm.@{db}.create.sql"
-			     url="${@{db}.hibernate.connection.url}"
-			     driver="${@{db}.hibernate.connection.driver_class}"
-			     classpathref="maven.compile.classpath"
-			     userid="${@{db}.hibernate.connection.username}"
-			     password="${@{db}.hibernate.connection.password}"
-			     autocommit="yes" continue="yes" />
-			<!-- generate schema upgrade script -->
-			<schemaupdate outputFile="${previous.version.dir}/jbpm.@{db}.update.sql"
-			              config="${@{db}.hibernate.cfg}"
-			              properties="${@{db}.hibernate.properties}"
-			              delimiter=";" />
+      <!-- calculate the difference beetween the previous and the current create schemas -->
+      <exec executable="diff"
+            osfamily="unix"
+            output="${previous.version.dir}/jbpm.@{db}.create.diff">
+        <arg value="-u" />
+        <arg file="${previous.version.dir}/jbpm.@{db}.create.sql" />
+        <arg file="${project.output.dir}/jbpm.@{db}.create.sql" />
+      </exec>
 
-			<echo>=====================</echo>
-		</sequential>
-	</macrodef>
+      <property name="@{db}.hibernate.cfg" value="src/main/config/@{db}.hibernate.cfg.xml" />
+      <property name="@{db}.hibernate.properties"
+                value="${user.home}/.jbpm4/jdbc/@{db}.properties" />
+      <property file="${@{db}.hibernate.properties}" prefix="@{db}" />
+      <echo>driver... ${@{db}.hibernate.connection.driver_class}</echo>
+      <echo>url...... ${@{db}.hibernate.connection.url}</echo>
+      <echo>username. ${@{db}.hibernate.connection.username}</echo>
+      <echo>password. ${@{db}.hibernate.connection.password}</echo>
+
+      <!-- drop current schema if exists -->
+      <sql src="${project.output.dir}/jbpm.@{db}.drop.sql"
+           url="${@{db}.hibernate.connection.url}"
+           driver="${@{db}.hibernate.connection.driver_class}"
+           classpathref="maven.compile.classpath"
+           userid="${@{db}.hibernate.connection.username}"
+           password="${@{db}.hibernate.connection.password}"
+           autocommit="yes"
+           onerror="continue" />
+      <!-- create previous version schema -->
+      <sql src="${previous.version.dir}/jbpm.@{db}.create.sql"
+           url="${@{db}.hibernate.connection.url}"
+           driver="${@{db}.hibernate.connection.driver_class}"
+           classpathref="maven.compile.classpath"
+           userid="${@{db}.hibernate.connection.username}"
+           password="${@{db}.hibernate.connection.password}"
+           autocommit="yes"
+           onerror="continue" />
+      <!-- generate schema upgrade script -->
+      <schemaupdate outputFile="${previous.version.dir}/jbpm.@{db}.update.sql"
+                    config="${@{db}.hibernate.cfg}"
+                    properties="${@{db}.hibernate.properties}"
+                    delimiter=";" />
+
+      <echo>=====================</echo>
+    </sequential>
+  </macrodef>
 </project>
\ No newline at end of file

Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml	2009-08-20 14:10:20 UTC (rev 5498)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml	2009-08-20 16:49:33 UTC (rev 5499)
@@ -184,7 +184,37 @@
 
   <section id="databasemigration">
     <title>Database migration</title>
-    <para>TODO: document the instructions how users should apply the automatic migration</para>
+    <para>jBPM is able to generate SQL DDL scripts to upgrade the database schema from any past version
+    starting from 4.0. To enact this capability, first check out the project from our SVN repository as
+    described in the Wiki page <ulink url="http://www.jboss.org/community/wiki/jbpm4buildingfromsource">
+    Building from Source</ulink>. Make sure you specify the appropriate database properties for your 
+    target database.</para>
+    <para>Afterwards, change to the <literal>modules/db</literal> directory and run:</para>
+    <synopsis>mvn -Djbpm.previous.version=&lt;version.number&gt;
+    -Ddatabase={hsqldb|mysql|postgresql|oracle} package</synopsis>
+    <para>The valid previous versions are those available from the JBoss <ulink 
+    url="http://repository.jboss.org/maven2/org/jbpm/jbpm4/jbpm-db/">Maven repo</ulink> starting
+    from 4.0.</para>
+    <para>Let us walk over an example. Assume you want to generate an update script from version 4.0
+    for PostgreSQL. You have checked out <ulink url="http://anonsvn.jboss.org/repos/jbpm/jbpm4/trunk/">trunk</ulink>.
+    You have a local PostgreSQL server listening on port 5432 (default). You have created a database and login
+    both called <literal>jbpm4</literal>. File <literal>&lt;user.home&gt;/.jbpm4/jdbc/postgresql.properties</literal>
+    contains your JDBC connection properties.</para>
+    <programlisting>hibernate.connection.driver_class=org.postgresql.Driver
+hibernate.connection.url=jdbc:postgresql://localhost:5432/jbpm4
+hibernate.connection.username=jbpm4
+hibernate.connection.password=</programlisting>
+    <para>Given the environment described above, you change to the <literal>modules/db</literal> directory
+    and run maven there.</para>
+    <synopsis>mvn -Djbpm.previous.version=4.0 -Ddatabase=postgresql package</synopsis>
+    <para>This command creates directory <literal>target/4.0</literal> and writes the following artifacts
+    there:</para>
+    <itemizedlist>
+      <listitem>Scripts to create and drop the jBPM 4.0 database schema, retrieved from the Maven repo.</listitem>
+      <listitem>PostgreSQL script to upgrade from the jBPM 4.0 schema to the version in your working copy.</listitem>
+      <listitem>Diff file between the previous and the current schema creation scripts. Only appears if your OS
+      belongs to the Unix family (including Linux and Mac OS X) and provides the diff command.</listitem>
+    </itemizedlist>
   </section>
 
   <section id="graphicalprocessdesigner">



More information about the jbpm-commits mailing list