You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-user@db.apache.org by Guy Davis <da...@guydavis.ca> on 2006/02/18 02:46:13 UTC

Ant/DDLUtils questions

Hi all,
 
I was hoping you would be able to answer a few of my questions about 
DDLUtils.  Some are questions about DDLUtils functionality; if DDLUtils 
can't do the request currently I'd like to hear if you think it could or 
whether it should.  I'd like to contribute (coding, testing, docs) to 
new features deemed useful and possible by the group.
 
1) The XML file of data dumped from DatabaseToDdl using writeDataToFile 
now loads without a DOCTYPE declaration being added when I use 
validateXml="false" in my DdlToDatabase tag.  (Thanks Thomas!)  However, 
the root tag of the the dump (from Oracle 10g EE) is just <database>.  
When I load, I get an error saying I need a 'name' attribute on the root 
tag.  If I manually add it giving: <database name='SomeName'> then my 
load works fine.  Is there any way to have the name added to the file 
automatically?  If so, what is the setting?
 
2) I am unable to get the ON DELETE CASCADE behavior of foreign keys to 
be recorded when dumping schema to XML.  I have verified that my Oracle 
table has a foreign key with Delete Rule set to Cascade, but a schema 
dump does not add `onDelete="cascade"` to the <foreign key> tag in the 
schema.xml.  I can add this attribute to the schema file manually, but a 
load (DdlToDatabase) seems to silently ignore them when creating 
tables.  Any ideas?
 
3) I'd like to add a db.clean target to my Ant build file that drops all 
everything (tables, etc) leaving an empty database.  Is there anything 
in DDLUtils that can do this for the different database types?
 
4) Is there any way to essentially diff two schema XML files and 
generate database-specific SQL that can be saved to a file?  Ideally, 
I'd like to use for handling database upgrades of our 
product.  This seems to be almost what the WriteSchemaToDatabase command 
is doing for a single schema and a live database with 
alterDatabase=true.   Would it be possible to replace the live database 
with a second schema and then have the SQL sent to a file rather than to 
the live database?
 
5) Similarly to #4, but diffing two sets of data that has been dumped to 
XML and generating database specific SQL.  Is this even possible for all 
the different ways to change data?  This seems much harder than #4.
 
Thanks in advance,
Guy

Re: Ant/DDLUtils questions

Posted by Guy Davis <da...@guydavis.ca>.
Thomas Dudziak wrote:

>>now loads without a DOCTYPE declaration being added when I use
>>validateXml="false" in my DdlToDatabase tag.  (Thanks Thomas!)  However,
>>the root tag of the the dump (from Oracle 10g EE) is just <database>.
>>When I load, I get an error saying I need a 'name' attribute on the root
>>tag.  If I manually add it giving: <database name='SomeName'> then my
>>load works fine.  Is there any way to have the name added to the file
>>automatically?  If so, what is the setting?
>>    
>>
> 1) The XML file of data dumped from DatabaseToDdl using writeDataToFile
>
>
>Is a bug, I think. I'll look into it.
>  
>
Added DDLUTILS-74 to JIRA.

>  
>
>>2) I am unable to get the ON DELETE CASCADE behavior of foreign keys to
>>be recorded when dumping schema to XML.  I have verified that my Oracle
>>table has a foreign key with Delete Rule set to Cascade, but a schema
>>dump does not add `onDelete="cascade"` to the <foreign key> tag in the
>>schema.xml.  I can add this attribute to the schema file manually, but a
>>load (DdlToDatabase) seems to silently ignore them when creating
>>tables.  Any ideas?
>>    
>>
>
>DdlUtils currently does not use the onUpdate and onDelete attributes.
>Could you file an improvement issue in JIRA ?
>  
>
Added DDLUTILS-75 to JIRA

>  
>
>>3) I'd like to add a db.clean target to my Ant build file that drops all
>>everything (tables, etc) leaving an empty database.  Is there anything
>>in DDLUtils that can do this for the different database types?
>>    
>>
>
>You could alter the database to an empty schema, which in effect
>should drop all tables and related constraints.
>  
>
Thanks, this idea worked great.

>>4) Is there any way to essentially diff two schema XML files and
>>generate database-specific SQL that can be saved to a file?  Ideally,
>>I'd like to use for handling database upgrades of our
>>product.  This seems to be almost what the WriteSchemaToDatabase command
>>is doing for a single schema and a live database with
>>alterDatabase=true.   Would it be possible to replace the live database
>>with a second schema and then have the SQL sent to a file rather than to
>>the live database?
>>    
>>
>
>You're right, this should be easy to implement. Again, could you file
>a feature request issue in JIRA ?
>  
>
Added DDLUTILS-76 to JIRA.

>>5) Similarly to #4, but diffing two sets of data that has been dumped to
>>XML and generating database specific SQL.  Is this even possible for all
>>the different ways to change data?  This seems much harder than #4.
>>    
>>
>
>Mhmm, I don't know. In general you would create DELETE (for rows that
>are not present in the target data set), INSERT (for rows that are not
>present in the source data set) and UPDATE statements (for each
>changed column).
>
>Tom
>  
>
Didn't add an item for this as I need to think about the various 
scenarios I'd hope it would cover.  The schema diff request above is 
more important to me right now anyway.

Thanks much,
Guy

Re: Ant/DDLUtils questions

Posted by Thomas Dudziak <to...@gmail.com>.
On 2/18/06, Guy Davis <da...@guydavis.ca> wrote:

> I was hoping you would be able to answer a few of my questions about
> DDLUtils.  Some are questions about DDLUtils functionality; if DDLUtils
> can't do the request currently I'd like to hear if you think it could or
> whether it should.  I'd like to contribute (coding, testing, docs) to
> new features deemed useful and possible by the group.

Sure. And contributions are always welcome.

> 1) The XML file of data dumped from DatabaseToDdl using writeDataToFile
> now loads without a DOCTYPE declaration being added when I use
> validateXml="false" in my DdlToDatabase tag.  (Thanks Thomas!)  However,
> the root tag of the the dump (from Oracle 10g EE) is just <database>.
> When I load, I get an error saying I need a 'name' attribute on the root
> tag.  If I manually add it giving: <database name='SomeName'> then my
> load works fine.  Is there any way to have the name added to the file
> automatically?  If so, what is the setting?

Is a bug, I think. I'll look into it.

> 2) I am unable to get the ON DELETE CASCADE behavior of foreign keys to
> be recorded when dumping schema to XML.  I have verified that my Oracle
> table has a foreign key with Delete Rule set to Cascade, but a schema
> dump does not add `onDelete="cascade"` to the <foreign key> tag in the
> schema.xml.  I can add this attribute to the schema file manually, but a
> load (DdlToDatabase) seems to silently ignore them when creating
> tables.  Any ideas?

DdlUtils currently does not use the onUpdate and onDelete attributes.
Could you file an improvement issue in JIRA ?

> 3) I'd like to add a db.clean target to my Ant build file that drops all
> everything (tables, etc) leaving an empty database.  Is there anything
> in DDLUtils that can do this for the different database types?

You could alter the database to an empty schema, which in effect
should drop all tables and related constraints.

> 4) Is there any way to essentially diff two schema XML files and
> generate database-specific SQL that can be saved to a file?  Ideally,
> I'd like to use for handling database upgrades of our
> product.  This seems to be almost what the WriteSchemaToDatabase command
> is doing for a single schema and a live database with
> alterDatabase=true.   Would it be possible to replace the live database
> with a second schema and then have the SQL sent to a file rather than to
> the live database?

You're right, this should be easy to implement. Again, could you file
a feature request issue in JIRA ?

> 5) Similarly to #4, but diffing two sets of data that has been dumped to
> XML and generating database specific SQL.  Is this even possible for all
> the different ways to change data?  This seems much harder than #4.

Mhmm, I don't know. In general you would create DELETE (for rows that
are not present in the target data set), INSERT (for rows that are not
present in the source data set) and UPDATE statements (for each
changed column).

Tom