db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r518485 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils/platform: hsqldb/HsqlDbBuilder.java mysql/MySqlBuilder.java
Date Thu, 15 Mar 2007 05:07:05 GMT
Author: tomdz
Date: Wed Mar 14 22:07:05 2007
New Revision: 518485

URL: http://svn.apache.org/viewvc?view=rev&rev=518485
Log:
Fixed Hsqldb/MySql sql builders

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java?view=diff&rev=518485&r1=518484&r2=518485
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java Wed
Mar 14 22:07:05 2007
@@ -81,6 +81,18 @@
                                                 Map      parameters,
                                                 List     changes) throws IOException
     {
+        // HsqlDb can only drop columns that are not part of a primary key
+        for (Iterator changeIt = changes.iterator(); changeIt.hasNext();)
+        {
+            TableChange change = (TableChange)changeIt.next();
+
+            if ((change instanceof RemoveColumnChange) && 
+                ((RemoveColumnChange)change).getColumn().isPrimaryKey())
+            {
+                return;
+            }
+        }
+
         // in order to utilize the ALTER TABLE ADD COLUMN BEFORE statement
         // we have to apply the add column changes in the correct order
         // thus we first gather all add column changes and then execute them
@@ -114,12 +126,8 @@
             {
                 RemoveColumnChange removeColumnChange = (RemoveColumnChange)change;
 
-                // HsqlDb can only drop columns that are not part of a primary key
-                if (!removeColumnChange.getColumn().isPrimaryKey())
-                {
-                    processChange(currentModel, desiredModel, removeColumnChange);
-                    changeIt.remove();
-                }
+                processChange(currentModel, desiredModel, removeColumnChange);
+                changeIt.remove();
             }
         }
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java?view=diff&rev=518485&r1=518484&r2=518485
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java Wed Mar
14 22:07:05 2007
@@ -183,6 +183,16 @@
 
             if (change instanceof AddColumnChange)
             {
+                AddColumnChange addColumnChange = (AddColumnChange)change;
+
+                if (addColumnChange.getNewColumn().isRequired() &&
+                    (addColumnChange.getNewColumn().getDefaultValue() == null) &&
+                    !addColumnChange.getNewColumn().isAutoIncrement())
+                {
+                    // we're enforcing a full rebuild in case of the addition of a required
+                    // column without a default value that is not autoincrement
+                    return;
+                }
                 addColumnChanges.add(change);
                 changeIt.remove();
             }



Mime
View raw message