Another possibility is to use DBUnit.
You could use it to take a snapshot of tables you'd like to preserve
data for, make your changes and then upload the data again, all from an
ant script. Of course there are drawbacks (such as renamed columns will
cause some grief) but this would often be ok for a dev/prototyping
situation.
In a nutshell for ant:
<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask"/>
<target name="dbexport" depends=""
description="Exports data from the database">
<dbunit driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.password}">
<export dest="${db.file}">
<table name="table1"/>
<table name="table2"/>
</export>
</dbunit>
</target>
<target name="dbinsert" depends="" unless="target"
description="Inserts data into the database">
<echo message="Inserting test data: ${db.url}, ${db.user}"/>
<dbunit driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.password}">
<operation type="INSERT" src="${db.file}"/>
</dbunit>
</target>
<target name="dbdelete" depends=""
unless="target"
description="Deletes data from the database">
<echo message="Deleting test data: ${db.url}, ${db.user}"/>
<dbunit driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.password}">
<operation type="DELETE" src="${db.file}"/>
</dbunit>
</target>
hope this helps...
----- Original message -----
From: "Andrus Adamchik" <andru..bjectstyle.org>
To: cayenne-use..bjectstyle.org
Date: Tue, 7 Sep 2004 01:00:09 -0400
Subject: Re: Update DB Schema
On Sep 6, 2004, at 11:42 PM, Kevin J. Menard, Jr. wrote:
> Hi,
>
> I have a project, and would like to modify the DB schema a bit (adding
> new columns) without deleting all of my existing data. I know the
> data modeler will create SQL commands to create tables, but is there
> any functionality for it to create update commands? If not, what's
> the best way to go about this? Update the SQL manually and the
> rebuild my model in the data modeler by reverse-engineering the DB
> schema? Or something different?
Hi Kevin,
If this is just such simple change, I would manually add a column to
DB, and then manually add a corresponding attribute to DbEntity in
CayenneModeler (and then you can "Sync ObjEntity with DbEntity).
Reverse-engineering may be an overkill, as you may loose some of the
model customizations (if you made any), such as flattened relationships
or non-default names.
Andrus
This archive was generated by hypermail 2.0.0 : Tue Sep 07 2004 - 02:16:26 EDT