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 Hank DeGregorio <he...@comcast.com> on 2007/10/22 21:00:54 UTC

DdlUtils DB enum column type

Hi,

I used the org.apache.ddlutils.task.DatabaseToDdlTask Ant task to generate
an XML representation of a MySQL DB as follows:

<target name="db-dump" description="Dumps the database structure">
  <taskdef name="databaseToDdl"
           classname="org.apache.ddlutils.task.DatabaseToDdlTask">
    <classpath refid="runtime-classpath"/>

  </taskdef>
  <databaseToDdl modelname="foo" verbosity="DEBUG">
    <database  url="jdbc:mysql://localhost/foo"
              driverclassname="com.mysql.jdbc.Driver"
              username="XXXX"
              password="YYYYYYYY"/>

    <writeSchemaToFile outputFile="db-schema.xml"/>
  </databaseToDdl>
</target>

The schema was created successfully, but columns typed as "enum" in MySQL
with a set of allowable values were converted to CHAR types in the XML.  For
example, 

<column name="entity_type1" primaryKey="false" required="false" type="CHAR"
size="3" autoIncrement="false"/>

was generated from a column definition that looks like so in MySQL DDL:

`entity_type1` enum('AA','BB','CC') default NULL

I realize the CHAR typing is valid, but I would like to generate the
database from scratch from the XML representation.  Is there a way to
preserve enums in the XML?

Thanks in advance,
Hank

-- 
Hank DeGregorio
Comcast Interactive Media



Re: DdlUtils DB enum column type

Posted by Thomas Dudziak <to...@gmail.com>.
Hi Hank,

On 10/22/07, Hank DeGregorio <he...@comcast.com> wrote:

> I used the org.apache.ddlutils.task.DatabaseToDdlTask Ant task to generate
> an XML representation of a MySQL DB as follows:
>
> <target name="db-dump" description="Dumps the database structure">
>   <taskdef name="databaseToDdl"
>            classname="org.apache.ddlutils.task.DatabaseToDdlTask">
>     <classpath refid="runtime-classpath"/>
>
>   </taskdef>
>   <databaseToDdl modelname="foo" verbosity="DEBUG">
>     <database  url="jdbc:mysql://localhost/foo"
>               driverclassname="com.mysql.jdbc.Driver"
>               username="XXXX"
>               password="YYYYYYYY"/>
>
>     <writeSchemaToFile outputFile="db-schema.xml"/>
>   </databaseToDdl>
> </target>
>
> The schema was created successfully, but columns typed as "enum" in MySQL
> with a set of allowable values were converted to CHAR types in the XML.  For
> example,
>
> <column name="entity_type1" primaryKey="false" required="false" type="CHAR"
> size="3" autoIncrement="false"/>
>
> was generated from a column definition that looks like so in MySQL DDL:
>
> `entity_type1` enum('AA','BB','CC') default NULL
>
> I realize the CHAR typing is valid, but I would like to generate the
> database from scratch from the XML representation.  Is there a way to
> preserve enums in the XML?

the column is read as type CHAR because that is what the JDBC driver
reports (since JDBC lacks an enum datatype). Enums would require
native type support in the database model which DdlUtils currently
does not have (see also
http://issues.apache.org/jira/browse/DDLUTILS-86).

Tom