db-ddlutils-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Dudziak" <tom...@gmail.com>
Subject Re: Problem with using DdlUtils with MySql
Date Mon, 18 Feb 2008 21:32:18 GMT
On Feb 14, 2008 6:39 AM, Satish Yellanki <satish.yellanki@ineoquest.com> wrote:

> I am using MySql5.0 and ddlutils 1.0.
> Here is the create table statement for the existing table:
> CREATE TABLE mytable (
>   column1 int(10) unsigned NOT NULL default '0',
>   column2 varchar(45) NOT NULL default '',
>   column3 varchar(7) NOT NULL default '',
>   column4 tinyint(3) unsigned default NULL,
>   column5 varchar(45) default NULL,
>   PRIMARY KEY  (column1)
> )
> The schema that is generated is:
> <table name="mytable">
>   <column name="column1" primaryKey="true" required="true"
> type="INTEGER" size="10" default="0" autoIncrement="false"/>
>   <column name="column2" primaryKey="false" required="true"
> type="VARCHAR" size="45" autoIncrement="false"/>
>   <column name="column3" primaryKey="false" required="true"
> type="VARCHAR" size="7" autoIncrement="false"/>
>   <column name="column4" primaryKey="false" required="false"
> type="TINYINT" size="3" autoIncrement="false"/>
>   <column name="column5" primaryKey="false" required="false"
> type="VARCHAR" size="45" autoIncrement="false"/>
> </table>
> I would like to see the default values also generated for columns 2 and
> 3 (default=""). The problem with the current output is that when I add a
> new column "column6 varchar(10) not null default ''", the schema
> generated does not include the default value. Then, when I try to
> upgrade an existing database to this new model, it tries to delete and
> recreate this table which is not what we want.
> Also, are there any plans to support the "unsigned" types in ddlutils?

There was a bug with writing out the default value to XML that I fixed
as part of http://issues.apache.org/jira/browse/DDLUTILS-193 in trunk.
You can work around this by simply adding


to the generated XML.
However, due to the fact that DdlUtils maps the jdbc tinyint type to
MySql's SMALLINT datatype because MySql's TINYINT is too small (signed
or unsigned). This will not change until
http://issues.apache.org/jira/browse/DDLUTILS-86 is implemented which
will basically allow you to override the default type mapping in the
XML on a per-platform basis.


View raw message