ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy Lambert <>
Subject Re: How to script database upgrade using ANT script
Date Thu, 04 Nov 2010 17:44:51 GMT
On 11/4/10 1:35 PM, Java Jboss wrote:
> Hi Antoine,
> Thank you for this update.  I am using a linux server.  I've been asked to do this in
ANT only.  Can you possibly provide me an example of how a similar process might be scripted
using ANT?
> As I have never used ANT or any other similar products before I am using Google for help.
I suggest that you start by reading the manual under first.

You would start by writing a build file for your work looking like that

<project name="databaseupgrade">
<target name="all" depends="createdatabase,loaddump,runscripts"/>
<target name="init">
<property name="databasename" value="mynewdatabase"/>
<target name="createdatabase" depends="init">
<exec command="sh" failonerror="true">
<arg value=""/>
<arg value="${databasename}"/>
<target name="loaddump">
<!-- some action goes here -->
<target name="runscripts">
<!-- some action gets here too -->
> Thank you.
> Date: Thu, 4 Nov 2010 09:46:31 -0700
> From:
> To:
> Subject: Re: How to script database upgrade using ANT script
> Hi,
> you will need to use the<exec/>  task for steps like creating the
> database and importing the dump into the new schema.
> Once your database is up, you can use the<sqlexec/>  task to run DDL and
> DML statements.
> To check whether a script exists, there is a task called<available/>
> which can set a property if a file is available.
> For error checking, you can run<exec/>  with failonerror="true" to stop
> your build if a script fails.
> You need to test before hand whether the system commands or the scripts
> that you will run to create the database and import the dump are
> returning proper exit statuses. (setting ERRORLEVEL on Windows or $? on
> UNIX).
> Regards,
> Antoine
> On 11/4/10 12:28 PM, Java Jboss wrote:
>> Hi,
>> I’m a complete newbie to ANT and I need to write an ant script which
>> upgrades a database version from base level 1.00 to a given version number
>> by running a series of mysql (ver 5.1.45) scripts.
>> Using ANT script I need to:
>> 1) create a database
>> 2) import mysql database(s) dump to a new schema
>> 3) check current database version
>> 4) then check if sql script1 exists
>> 4.1) if "No" then check for next sql script until it has checked for all
>> scripts then "end"
>> 4.2) if "yes" then run first sql script then check if second sql script
>> exists - if "yes" then run second sql script and so on until the required
>> database version is reached.
>> 5) check database version is at correct level then “end” or else start the
>> loop again
>> 6) how can I script error checking also
>> Thank you all in advance.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
> View message @
> To unsubscribe from How to script database upgrade using ANT script, click here.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message