db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r602807 [12/15] - in /db/ddlutils/trunk: ./ src/java/org/apache/ddlutils/ src/java/org/apache/ddlutils/alteration/ src/java/org/apache/ddlutils/model/ src/java/org/apache/ddlutils/platform/ src/java/org/apache/ddlutils/platform/axion/ src/j...
Date Mon, 10 Dec 2007 08:21:39 GMT
Added: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAddColumn.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAddColumn.java?rev=602807&view=auto
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAddColumn.java (added)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAddColumn.java Mon Dec 10 00:20:47 2007
@@ -0,0 +1,3416 @@
+package org.apache.ddlutils.io;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.math.BigDecimal;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.apache.commons.beanutils.DynaBean;
+import org.apache.ddlutils.platform.db2.Db2Platform;
+import org.apache.ddlutils.platform.db2.Db2v8Platform;
+import org.apache.ddlutils.platform.hsqldb.HsqlDbPlatform;
+import org.apache.ddlutils.platform.interbase.InterbasePlatform;
+import org.apache.ddlutils.platform.maxdb.MaxDbPlatform;
+import org.apache.ddlutils.platform.mysql.MySql50Platform;
+import org.apache.ddlutils.platform.mysql.MySqlPlatform;
+import org.apache.ddlutils.platform.sapdb.SapDbPlatform;
+import org.apache.ddlutils.platform.sybase.SybasePlatform;
+
+/**
+ * Tests database alterations that add columns.
+ * 
+ * @version $Revision: $
+ */
+public class TestAddColumn extends RoundtripTestBase
+{
+    /**
+     * Parameterized test case pattern.
+     * 
+     * @return The tests
+     */
+    public static Test suite() throws Exception
+    {
+        return getTests(TestAddColumn.class);
+    }
+
+    /**
+     * Tests the addition of a column.
+     */
+    public void testAddColumn()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='32'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+    	alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)null, beans.get(0), "avalue");
+    }
+
+    /**
+     * Tests the addition of an auto-increment column.
+     */
+    public void testAddAutoIncrementColumn()
+    {
+    	if (!getPlatformInfo().isNonPKIdentityColumnsSupported())
+    	{
+    		return;
+    	}
+
+        // we need special catering for Sybase which does not support identity for INTEGER columns
+        boolean      isSybase  = SybasePlatform.DATABASENAME.equals(getPlatform().getName());
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml;
+
+        if (isSybase)
+        {
+            model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                        "<database name='roundtriptest'>\n"+
+                        "  <table name='roundtrip'>\n"+
+                        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+                        "    <column name='avalue' type='NUMERIC' size='12,0' autoIncrement='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+        else
+        {
+            model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                        "<database name='roundtriptest'>\n"+
+                        "  <table name='roundtrip'>\n"+
+                        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+                        "    <column name='avalue' type='INTEGER' autoIncrement='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+    	alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (isSybase)
+        {
+            assertEquals(new BigDecimal(1), beans.get(0), "avalue");
+        }
+        else
+        {
+            Object avalue = ((DynaBean)beans.get(0)).get("avalue");
+
+            assertTrue((avalue == null) || new Integer(1).equals(avalue));
+        }
+    }
+
+    /**
+     * Tests the addition of another auto-increment column.
+     */
+    public void testAddSecondAutoIncrementColumn()
+    {
+        if (!getPlatformInfo().isNonPKIdentityColumnsSupported() ||
+            SybasePlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MaxDbPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            SapDbPlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // Sybase and MaxDb/SapDb does not support more than one identity column per table
+            return;
+        }
+
+        final String model1Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                                 "<database name='roundtriptest'>\n"+
+                                 "  <table name='roundtrip'>\n"+
+                                 "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+                                 "    <column name='avalue1' type='INTEGER' autoIncrement='true'/>\n"+
+                                 "  </table>\n"+
+                                 "</database>";
+        final String model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                                 "<database name='roundtriptest'>\n"+
+                                 "  <table name='roundtrip'>\n"+
+                                 "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+                                 "    <column name='avalue1' type='INTEGER' autoIncrement='true'/>\n"+
+                                 "    <column name='avalue2' type='INTEGER' autoIncrement='true'/>\n"+
+                                 "  </table>\n"+
+                                 "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List   beans   = getRows("roundtrip");
+        Object avalue1 = ((DynaBean)beans.get(0)).get("avalue1");
+        Object avalue2 = ((DynaBean)beans.get(0)).get("avalue2");
+
+        assertTrue((avalue1 == null) || new Integer(1).equals(avalue1));
+        assertTrue((avalue2 == null) || new Integer(1).equals(avalue2));
+    }
+
+    /**
+     * Tests the addition of a column that is set to NOT NULL.
+     */
+    public void testAddRequiredColumn()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='NUMERIC' size='12,0' default='2' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new BigDecimal(2), beans.get(0), "avalue");
+    }
+
+    /**
+     * Tests the addition of a column with a default value. Note that depending
+     * on whether the database supports this via a statement, this test may fail.
+     * For instance, Sql Server has a statement for this which means that the
+     * existing value in column avalue won't be changed and thus the test fails.
+     */
+    public void testAddColumnWithDefault()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DOUBLE' default='2'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        // we cannot be sure whether the default algorithm is used (which will apply the
+        // default value even to existing columns with NULL in it) or the database supports
+        // it directly (in which case it might still be NULL)
+        Object avalue = ((DynaBean)beans.get(0)).get("avalue");
+
+        assertTrue((avalue == null) || new Double(2).equals(avalue));
+    }
+
+    /**
+     * Tests the addition of a required auto-increment column.
+     */
+    public void testAddRequiredAutoIncrementColumn()
+    {
+        if (!getPlatformInfo().isNonPKIdentityColumnsSupported())
+        {
+            return;
+        }
+
+        // we need special catering for Sybase which does not support identity for INTEGER columns
+        boolean      isSybase  = SybasePlatform.DATABASENAME.equals(getPlatform().getName());
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml;
+
+        if (isSybase)
+        {
+            model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                        "<database name='roundtriptest'>\n"+
+                        "  <table name='roundtrip'>\n"+
+                        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+                        "    <column name='avalue' type='NUMERIC' size='12,0' autoIncrement='true' required='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+        else
+        {
+            model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                        "<database name='roundtriptest'>\n"+
+                        "  <table name='roundtrip'>\n"+
+                        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+                        "    <column name='avalue' type='INTEGER' autoIncrement='true' required='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (isSybase)
+        {
+            assertEquals(new BigDecimal(1), beans.get(0), "avalue");
+        }
+        else
+        {
+            Object avalue = ((DynaBean)beans.get(0)).get("avalue");
+
+            assertTrue((avalue == null) || new Integer(1).equals(avalue));
+        }
+    }
+
+    /**
+     * Tests the addition of a column with a default value. Note that depending
+     * on whether the database supports this via a statement, this test may fail.
+     * For instance, Sql Server has a statement for this which means that the
+     * existing value in column avalue won't be changed and thus the test fails.
+     */
+    public void testAddRequiredColumnWithDefault()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='CHAR' size='8' default='sometext' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        // we cannot be sure whether the default algorithm is used (which will apply the
+        // default value even to existing columns with NULL in it) or the database supports
+        // it directly (in which case it might still be NULL)
+        Object avalue = ((DynaBean)beans.get(0)).get("avalue");
+
+        assertTrue((avalue == null) || "sometext".equals(avalue));
+    }
+
+    /**
+     * Tests the addition of several columns at the end of the table.
+     */
+    public void testAddMultipleColumns()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='VARCHAR' size='32'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='VARCHAR' size='32'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "    <column name='avalue3' type='DOUBLE' default='1.0'/>\n"+
+            "    <column name='avalue4' type='VARCHAR' size='16'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), "test", new Integer(3) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)"test", beans.get(0), "avalue1");
+        assertEquals(new Integer(3), beans.get(0), "avalue2");
+
+        // we cannot be sure whether the default algorithm is used (which will apply the
+        // default value even to existing columns with NULL in it) or the database supports
+        // it dircetly (in which case it might still be NULL)
+        Object avalue3 = ((DynaBean)beans.get(0)).get("avalue3");
+
+        assertTrue((avalue3 == null) || new Double(1.0).equals(avalue3));
+        
+        assertEquals((Object)null, beans.get(0), "avalue4");
+    }
+
+    /**
+     * Tests the addition of a primary key and a column.
+     */
+    public void testAddPKAndColumn()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "    <column name='pk' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            // MySql uses an empty string to initialize the new pk column
+            assertEquals((Object)"",     beans.get(0), "pk");
+            assertEquals(new Integer(1), beans.get(0), "avalue");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of a primary key and an autoincrement column.
+     */
+    public void testAddPKAndAutoIncrementColumn()
+    {
+        // we need special catering for Sybase which does not support identity for INTEGER columns
+        boolean      isSybase  = SybasePlatform.DATABASENAME.equals(getPlatform().getName());
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml;
+
+        if (isSybase)
+        {
+            model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                        "<database name='roundtriptest'>\n"+
+                        "  <table name='roundtrip'>\n"+
+                        "    <column name='avalue' type='INTEGER'/>\n"+
+                        "    <column name='pk' type='NUMERIC' size='12,0' primaryKey='true' required='true' autoIncrement='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+        else
+        {
+            model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                        "<database name='roundtriptest'>\n"+
+                        "  <table name='roundtrip'>\n"+
+                        "    <column name='avalue' type='INTEGER'/>\n"+
+                        "    <column name='pk' type='INTEGER' primaryKey='true' required='true' autoIncrement='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "avalue");
+        if (isSybase)
+        {
+            assertEquals(new BigDecimal(1), beans.get(0), "pk");
+        }
+        else
+        {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+        }
+    }
+
+    /**
+     * Tests the addition of a primary key and multiple columns.
+     */
+    public void testAddPKAndMultipleColumns()
+    {
+        if (Db2Platform.DATABASENAME.equals(getPlatform().getName()) ||
+            Db2v8Platform.DATABASENAME.equals(getPlatform().getName()) ||
+            SybasePlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            InterbasePlatform.DATABASENAME.equals(getPlatform().getName())) {
+            // Db2, Sybase, Interbase require that all primary key columns be required, but they don't make them so automatically
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk3' type='DOUBLE' primaryKey='true' default='2'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(0),  beans.get(0), "pk1");
+            assertEquals((Object)"",      beans.get(0), "pk2");
+            assertEquals(new Double(2.0), beans.get(0), "pk3");
+            assertEquals(new Integer(1),  beans.get(0), "avalue");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of a primary key and multiple required columns.
+     */
+    public void testAddPKAndMultipleRequiredColumns()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk3' type='DOUBLE' primaryKey='true' required='true' default='2'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(0),  beans.get(0), "pk1");
+            assertEquals((Object)"",      beans.get(0), "pk2");
+            assertEquals(new Double(2.0), beans.get(0), "pk3");
+            assertEquals(new Integer(1),  beans.get(0), "avalue");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of a primary key and multiple columns.
+     */
+    public void testAddPKAndMultipleColumnsInclAutoIncrement()
+    {
+        if (HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // the IDENTITY column has to be the only PK column
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true' autoIncrement='true'/>\n"+
+            "    <column name='pk2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk3' type='DOUBLE' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        assertTrue(getRows("roundtrip").isEmpty());
+    }
+
+    /**
+     * Tests the addition of a column to a primary key.
+     */
+    public void testAddColumnIntoPK()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "    <column name='pk2' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(1),  beans.get(0), "pk1");
+            assertEquals(new Integer(0),  beans.get(0), "pk2");
+            assertEquals(new Integer(2),  beans.get(0), "avalue");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of an autoincrement column into the primary key.
+     */
+    public void testAddAutoIncrementColumnIntoPK()
+    {
+        if (HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // the IDENTITY column has to be the only PK column
+            return;
+        }
+
+        // we need special catering for Sybase which does not support identity for INTEGER columns
+        boolean      isSybase  = SybasePlatform.DATABASENAME.equals(getPlatform().getName());
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml;
+
+        if (isSybase)
+        {
+            model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                        "<database name='roundtriptest'>\n"+
+                        "  <table name='roundtrip'>\n"+
+                        "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+                        "    <column name='avalue' type='INTEGER'/>\n"+
+                        "    <column name='pk2' type='NUMERIC' size='12,0' primaryKey='true' required='true' autoIncrement='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+        else
+        {
+            model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                        "<database name='roundtriptest'>\n"+
+                        "  <table name='roundtrip'>\n"+
+                        "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+                        "    <column name='avalue' type='INTEGER'/>\n"+
+                        "    <column name='pk2' type='INTEGER' primaryKey='true' required='true' autoIncrement='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(-1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(-1), ((DynaBean)beans.get(0)).get("pk1"));
+        assertEquals(new Integer(2), ((DynaBean)beans.get(0)).get("avalue"));
+        if (isSybase)
+        {
+            assertEquals(new BigDecimal(1), beans.get(0), "pk2");
+        }
+        else
+        {
+            assertEquals(new Integer(1), beans.get(0), "pk2");
+        }
+    }
+
+    /**
+     * Tests the addition of multiple columns into the primary key.
+     */
+    public void testAddMultipleColumnsIntoPK()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "    <column name='pk2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk3' type='DOUBLE' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(1),  beans.get(0), "pk1");
+            assertEquals((Object)"",      beans.get(0), "pk2");
+            assertEquals(new Double(0.0), beans.get(0), "pk3");
+            assertEquals((Object)null,    beans.get(0), "avalue");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of multiple columns into the primary key which has an auto increment column.
+     */
+    public void testAddMultipleColumnsIntoPKWithAutoIncrement()
+    {
+        if (HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // the IDENTITY column has to be the only PK column
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true' autoIncrement='true'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true' autoIncrement='true'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "    <column name='pk2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk3' type='DOUBLE' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        assertTrue(getRows("roundtrip").isEmpty());
+    }
+
+    /**
+     * Tests the addition of multiple columns including one with auto increment into the primary key.
+     */
+    public void testAddMultipleColumnsInclAutoIncrementIntoPK()
+    {
+        if (HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // the IDENTITY column has to be the only PK column
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "    <column name='pk2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true' autoIncrement='true'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "    <column name='pk2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk3' type='DOUBLE' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), "text" });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        assertTrue(getRows("roundtrip").isEmpty());
+    }
+
+    /**
+     * Tests the addition of a non-unique index and a column.
+     */
+    public void testAddNonUniqueIndexAndColumn()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='32'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)null, beans.get(0), "avalue");
+    }
+
+    /**
+     * Tests the addition of a non-unique index and an auto increment column.
+     */
+    public void testAddNonUniqueIndexAndAutoIncrementColumn()
+    {
+        if (!getPlatformInfo().isIndicesSupported() || !getPlatformInfo().isNonPKIdentityColumnsSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' autoIncrement='true'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List   beans  = getRows("roundtrip");
+        Object avalue = ((DynaBean)beans.get(0)).get("avalue");
+
+        assertTrue((avalue == null) || new Integer(1).equals(avalue));
+    }
+
+    /**
+     * Tests the addition of a non-unique index and a required column.
+     */
+    public void testAddNonUniqueIndexAndRequiredColumn()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='NUMERIC' size='12,0' required='true'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(1),    beans.get(0), "pk");
+            assertEquals(new BigDecimal(0), beans.get(0), "avalue");
+        }
+        else if (InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals((Object)null,   beans.get(0), "avalue");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of a non-unique index and a column with a default value.
+     */
+    public void testAddNonUniqueIndexAndColumnWithDefault()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DOUBLE' default='2'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List   beans  = getRows("roundtrip");
+        Object avalue = ((DynaBean)beans.get(0)).get("avalue");
+
+        assertTrue((avalue == null) || new Double(2).equals(avalue));
+    }
+
+    /**
+     * Tests the addition of a non-unique index and a required auto increment column.
+     */
+    public void testAddNonUniqueIndexAndRequiredAutoIncrementColumn()
+    {
+        if (!getPlatformInfo().isIndicesSupported() || !getPlatformInfo().isNonPKIdentityColumnsSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' required='true' autoIncrement='true'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals((Object)null,   beans.get(0), "avalue");
+        }
+        else
+        {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals(new Integer(1), beans.get(0), "avalue");
+        }
+    }
+
+    /**
+     * Tests the addition of a non-unique index and a required column with a default value.
+     */
+    public void testAddNonUniqueIndexAndRequiredColumnWithDefault()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='CHAR' size='8' required='true' default='sometext'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)"sometext", beans.get(0), "avalue");
+    }
+
+    /**
+     * Tests the addition of a non-unique index and several columns.
+     */
+    public void testAddNonUniqueIndexAndMultipleColumns()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' default='1'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='32' required='true'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals(new Integer(1), beans.get(0), "avalue1");
+            assertEquals((Object)"",     beans.get(0), "avalue2");
+        }
+        else if (InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals((Object)null,   beans.get(0), "avalue1");
+            assertEquals((Object)null,   beans.get(0), "avalue2");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+
+    /**
+     * Tests the addition of an unique index and a column.
+     */
+    public void testAddUniqueIndexAndColumn()
+    {
+        if (!getPlatformInfo().isIndicesSupported() ||
+            InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='32'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)null, beans.get(0), "avalue");
+    }
+
+    /**
+     * Tests the addition of an unique index and an auto increment column.
+     */
+    public void testAddUniqueIndexAndAutoIncrementColumn()
+    {
+        if (!getPlatformInfo().isIndicesSupported() || !getPlatformInfo().isNonPKIdentityColumnsSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' autoIncrement='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List   beans  = getRows("roundtrip");
+        Object avalue = ((DynaBean)beans.get(0)).get("avalue");
+
+        assertTrue((avalue == null) || new Integer(1).equals(avalue));
+    }
+
+    /**
+     * Tests the addition of an unique index and a required column.
+     */
+    public void testAddUniqueIndexAndRequiredColumn()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='NUMERIC' size='12,0' required='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(1),    beans.get(0), "pk");
+            assertEquals(new BigDecimal(0), beans.get(0), "avalue");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of an unique index and a column with a default value.
+     */
+    public void testAddUniqueIndexAndColumnWithDefault()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DOUBLE' default='2'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List   beans  = getRows("roundtrip");
+        Object avalue = ((DynaBean)beans.get(0)).get("avalue");
+
+        assertTrue((avalue == null) || new Double(2).equals(avalue));
+    }
+
+    /**
+     * Tests the addition of an unique index and a required auto increment column.
+     */
+    public void testAddUniqueIndexAndRequiredAutoIncrementColumn()
+    {
+        if (!getPlatformInfo().isIndicesSupported() || !getPlatformInfo().isNonPKIdentityColumnsSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' required='true' autoIncrement='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "avalue");
+    }
+
+    /**
+     * Tests the addition of an unique index and a required column with a default value.
+     */
+    public void testAddUniqueIndexAndRequiredColumnWithDefault()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='CHAR' size='8' required='true' default='sometext'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)"sometext", beans.get(0), "avalue");
+    }
+
+    /**
+     * Tests the addition of an unique index and several columns.
+     */
+    public void testAddUniqueIndexAndMultipleColumns()
+    {
+        if (!getPlatformInfo().isIndicesSupported() ||
+            InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' default='1'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='32' required='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals(new Integer(1), beans.get(0), "avalue1");
+            assertEquals((Object)"",     beans.get(0), "avalue2");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of an unique index and several required columns.
+     */
+    public void testAddUniqueIndexAndMultipleRequiredColumns()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' required='true' default='1'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='32' required='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals(new Integer(1), beans.get(0), "avalue1");
+            assertEquals((Object)"",     beans.get(0), "avalue2");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of a column into a non-unique index.
+     */
+    public void testAddColumnIntoNonUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='32'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(2), beans.get(0), "avalue1");
+        assertEquals((Object)null,   beans.get(0), "avalue2");
+    }
+
+    /**
+     * Tests the addition of an auto increment column into a non-unique index.
+     */
+    public void testAddAutoIncrementColumnIntoNonUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported() || !getPlatformInfo().isNonPKIdentityColumnsSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='INTEGER' autoIncrement='true'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List   beans   = getRows("roundtrip");
+        Object avalue2 = ((DynaBean)beans.get(0)).get("avalue2");
+
+        assertEquals(new Integer(2), beans.get(0), "avalue1");
+        assertTrue((avalue2 == null) || new Integer(1).equals(avalue2));
+    }
+
+    /**
+     * Tests the addition of a required column into a non-unique index.
+     */
+    public void testAddRequiredColumnIntoNonUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='NUMERIC' size='12,0' required='true'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(1),    beans.get(0), "pk");
+            assertEquals(new Integer(2),    beans.get(0), "avalue1");
+            assertEquals(new BigDecimal(0), beans.get(0), "avalue2");
+        }
+        else if (InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals(new Integer(2), beans.get(0), "avalue1");
+            assertEquals((Object)null,   beans.get(0), "avalue2");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of a column with a default value into a non-unique index.
+     */
+    public void testAddColumnWithDefaultIntoNonUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='DOUBLE' default='2'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List   beans   = getRows("roundtrip");
+        Object avalue2 = ((DynaBean)beans.get(0)).get("avalue2");
+
+        assertEquals(new Integer(2), beans.get(0), "avalue1");
+        assertTrue((avalue2 == null) || new Double(2).equals(avalue2));
+    }
+
+    /**
+     * Tests the addition of a required auto increment column into a non-unique index.
+     */
+    public void testAddRequiredAutoIncrementColumnIntoNonUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported() || !getPlatformInfo().isNonPKIdentityColumnsSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='INTEGER' autoIncrement='true' required='true'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals(new Integer(2), beans.get(0), "avalue1");
+            assertEquals((Object)null,   beans.get(0), "avalue2");
+        }
+        else
+        {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals(new Integer(2), beans.get(0), "avalue1");
+            assertEquals(new Integer(1), beans.get(0), "avalue2");
+        }
+    }
+
+    /**
+     * Tests the addition of a required column with a default value into a non-unique index.
+     */
+    public void testAddRequiredColumnWithDefaultIntoNonUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='CHAR' size='8' default='sometext' required='true'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(2),     beans.get(0), "avalue1");
+        assertEquals((Object)"sometext", beans.get(0), "avalue2");
+    }
+
+    /**
+     * Tests the addition of multiple columns into a non-unique index.
+     */
+    public void testAddMultipleColumnsIntoNonUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='INTEGER' default='3'/>\n"+
+            "    <column name='avalue3' type='DOUBLE' required='true'/>\n"+
+            "    <index name='test'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "      <index-column name='avalue3'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            assertEquals(new Integer(1),  beans.get(0), "pk");
+            assertEquals(new Integer(2),  beans.get(0), "avalue1");
+            assertEquals(new Integer(3),  beans.get(0), "avalue2");
+            assertEquals(new Double(0.0), beans.get(0), "avalue3");
+        }
+        else if (InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            assertEquals(new Integer(1), beans.get(0), "pk");
+            assertEquals(new Integer(2), beans.get(0), "avalue1");
+            assertEquals((Object)null,   beans.get(0), "avalue2");
+            assertEquals((Object)null,   beans.get(0), "avalue3");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of a column into an unique index.
+     */
+    public void testAddColumnIntoUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported() ||
+            InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' required='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' required='true'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='32'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(2), beans.get(0), "avalue1");
+        assertEquals((Object)null,   beans.get(0), "avalue2");
+    }
+
+    /**
+     * Tests the addition of an auto increment column into an unique index.
+     */
+    public void testAddAutoIncrementColumnIntoUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported() ||
+            !getPlatformInfo().isNonPKIdentityColumnsSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' required='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' required='true'/>\n"+
+            "    <column name='avalue2' type='INTEGER' autoIncrement='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List   beans   = getRows("roundtrip");
+        Object avalue2 = ((DynaBean)beans.get(0)).get("avalue2");
+
+        assertEquals(new Integer(2), beans.get(0), "avalue1");
+        assertTrue((avalue2 == null) || new Integer(1).equals(avalue2));
+    }
+
+    /**
+     * Tests the addition of a required column into an unique index.
+     */
+    public void testAddRequiredColumnIntoUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' required='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' required='true'/>\n"+
+            "    <column name='avalue2' type='NUMERIC' size='12,0' required='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) {
+            // MySql uses the default value for the column's type to initialize
+            // the new column for existing rows
+            assertEquals(new Integer(1),    beans.get(0), "pk");
+            assertEquals(new Integer(2),    beans.get(0), "avalue1");
+            assertEquals(new BigDecimal(0), beans.get(0), "avalue2");
+        }
+        else {
+            assertTrue(beans.isEmpty());
+        }
+    }
+
+    /**
+     * Tests the addition of a column with a default value into an unique index.
+     */
+    public void testAddColumnWithDefaultIntoUniqueIndex()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' required='true'/>\n"+
+            "    <unique name='test'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+

[... 1192 lines stripped ...]


Mime
View raw message