You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Bruce Altner <ba...@hq.nasa.gov> on 2002/01/29 14:49:42 UTC

Adding tables to an existing database

Greetings:

I'm sure that this must be a FAQ but I can't find it in the docs anywhere...

What is the recommended practice for adding tables to an already 
established database? Do you go back to the beginning and run ant init on 
the entire (revised) schema so that Torque can create the new Peer classes 
or do you create them manually, using the existing classes as a model? The 
former approach would be easier, I think, but you'd have to back up your data.

There is a boolean switch in build.properties called 
"database.manual.creation." If this is set to true does Torque build the 
Peer classes but allow you to add the tables manually, preserving your 
existing tables (and data!)?

Thanks,
Bruce


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Adding tables to an existing database

Posted by Bruce Altner <ba...@hq.nasa.gov>.
Yes, this is just what I needed and it works great. Thanks very much.

Bruce

> > What is the recommended practice for adding tables to an already
> > established database? Do you go back to the beginning and run ant init on
> > the entire (revised) schema so that Torque can create the new Peer classes
> > or do you create them manually, using the existing classes as a model? The
> > former approach would be easier, I think, but you'd have to back up your
>data.
>
>If your application is such that you can wipe the database then "ant init"
>will do what you want.  This will not be an option for a production system
>where yo need to retain the data.  As I must ultimately deploy my changes
>to a production system, I work on my development database the same way
>as production so that I can produce the scripts that I will later apply
>there.
>
>To do this, I update my schema file, execute the ant project-om target to
>regenerate the peer classes and ant compile to compile them.  I also execute
>ant project-sql to produce the sql that would be used if I was to init the
>project - I do this only because it is sometimes useful to refer to
>{project}-schema.sql while manually producing the sql script to alter
>the database structure.  Producing and executing the sql script and making
>sure everything works as expected are obviously last steps.
>
> > There is a boolean switch in build.properties called
> > "database.manual.creation." If this is set to true does Torque build the
> > Peer classes but allow you to add the tables manually, preserving your
> > existing tables (and data!)?
>
>I am pretty sure this is the case.  Backup your database and try it ;-)
>
> > Thanks,
> > Bruce
>
>Cheers,
>
>Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Adding tables to an existing database

Posted by Scott Eade <se...@backstagetech.com.au>.
From: "Bruce Altner" <ba...@hq.nasa.gov>
> Greetings:
>
> I'm sure that this must be a FAQ but I can't find it in the docs
anywhere...

Not sure if it is.

> What is the recommended practice for adding tables to an already
> established database? Do you go back to the beginning and run ant init on
> the entire (revised) schema so that Torque can create the new Peer classes
> or do you create them manually, using the existing classes as a model? The
> former approach would be easier, I think, but you'd have to back up your
data.

If your application is such that you can wipe the database then "ant init"
will do what you want.  This will not be an option for a production system
where yo need to retain the data.  As I must ultimately deploy my changes
to a production system, I work on my development database the same way
as production so that I can produce the scripts that I will later apply
there.

To do this, I update my schema file, execute the ant project-om target to
regenerate the peer classes and ant compile to compile them.  I also execute
ant project-sql to produce the sql that would be used if I was to init the
project - I do this only because it is sometimes useful to refer to
{project}-schema.sql while manually producing the sql script to alter
the database structure.  Producing and executing the sql script and making
sure everything works as expected are obviously last steps.

> There is a boolean switch in build.properties called
> "database.manual.creation." If this is set to true does Torque build the
> Peer classes but allow you to add the tables manually, preserving your
> existing tables (and data!)?

I am pretty sure this is the case.  Backup your database and try it ;-)

> Thanks,
> Bruce

Cheers,

Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Adding tables to an existing database

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Bruce Altner <ba...@hq.nasa.gov> writes:

> Greetings:
>
> I'm sure that this must be a FAQ but I can't find it in the docs anywhere...
>
> What is the recommended practice for adding tables to an already
> established database? Do you go back to the beginning and run ant init
> on the entire (revised) schema so that Torque can create the new Peer
> classes or do you create them manually, using the existing classes as
> a model? The former approach would be easier, I think, but you'd have
> to back up your data.
>
> There is a boolean switch in build.properties called
> "database.manual.creation." If this is set to true does Torque build
> the Peer classes but allow you to add the tables manually, preserving
> your existing tables (and data!)?

Here's the relevant code from the build file:

  <target 
    name="init"
    depends="setup-webinf"
    description="--> generates the full application">
    
    <antcall target="create-database"/>
    <antcall target="schema-sql"/>
    <antcall target="idtable-init-sql"/>
    <antcall target="security-sql"/>
    <antcall target="insert-sql-files"/>
    <antcall target="update-tr-props"/>
    <antcall target="project-om"/>
    <antcall target="compile"/>
  </target>

I didn't notice the insert-sql-files gated by the
database.manual.creation property (which could be dangerous).  You'll
definitely get your OM/Peer class regenerated.  Jason, care to
comment?

Dan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>