db-ddlutils-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Satish Yellanki" <satish.yella...@ineoquest.com>
Subject RE: Problem with using DdlUtils with MySql
Date Thu, 14 Feb 2008 14:39:14 GMT
Hi Tom,

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?

Thanks for your quick response.

- Satish

-----Original Message-----
From: Thomas Dudziak [mailto:tomdzk@gmail.com] 
Sent: Wednesday, February 13, 2008 10:19 PM
To: ddlutils-user@db.apache.org
Subject: Re: Problem with using DdlUtils with MySql

Hi Satish,

could you post the definition of the existing table (i.e. the CREATE
TABLE statement), and the part from the schema XML that defines how
this table should look like ? Also, which MySql version are you using
?

Tom

On Feb 12, 2008 3:05 PM, Satish Yellanki <satish.yellanki@ineoquest.com>
wrote:
> Hello,
>
> I am trying to use DdlUtil with MySql database to upgrade from one
> version to another. I create a model file from the latest schema and
try
> to alter an existing database to match that file. However, there is
> problem with the default values.
>
> Some of the columns have default values defined as "" (empty string),
> while some don't have any default values. However, the DdlUtils
package
> out of the box is treating them the same... the xml output I create
does
> not have any default values in it.
>
> When I add a new column to the database which is "NOT NULL" and has a
> default value of "", the utility is trying to delete the existing
table
> and recreate it. I understand that this is because the utility assumes
> there is no default value and since it cannot add a NOT NULL column
> without a default, it is deleting and re-creating the table.
>
> Is there a way I can make MySql handler treat the "" (Empty String)
and
> null values differently and also, save the "" default values in the
> model file? This could potentially solve my problem.
>
> Thanks,
>
> Satish

Mime
View raw message