Package org.apache.ddlutils.alteration

Examples of org.apache.ddlutils.alteration.AddColumnChange


        {
            TableChange change = (TableChange)changeIt.next();

            if (change instanceof AddColumnChange)
            {
              AddColumnChange addColumnChange = (AddColumnChange)change;

              // TODO: we cannot add columns to the primary key this way
              //       because we would have to drop the pk first and then
              //       add a new one afterwards which is not supported yet
              if (addColumnChange.getNewColumn().isPrimaryKey())
                {
                    pkColumnAdded = true;  
                }
                else
              {
View Full Code Here


        {
            TableChange change = (TableChange)changeIt.next();

            if (change instanceof AddColumnChange)
            {
                AddColumnChange addColumnChange = (AddColumnChange)change;

                // Sql Server can only add not insert columns
                if (addColumnChange.isAtEnd())
                {
                    processChange(currentModel, desiredModel, addColumnChange);
                    changeIt.remove();
                }
            }
View Full Code Here

                changeIt.remove();
            }
        }
        for (ListIterator changeIt = addColumnChanges.listIterator(addColumnChanges.size()); changeIt.hasPrevious();)
        {
            AddColumnChange addColumnChange = (AddColumnChange)changeIt.previous();

            processChange(currentModel, desiredModel, addColumnChange);
            changeIt.remove();
        }
View Full Code Here

        {
            TableChange change = (TableChange)changeIt.next();

            if (change instanceof AddColumnChange)
            {
                AddColumnChange addColumnChange = (AddColumnChange)change;

                // SapDB can only add not insert columns
                if (!addColumnChange.isAtEnd())
                {
                    return;
                }
            }
        }
View Full Code Here

                                                autoIncrChange.getColumn());
                }
            }
            else if (change instanceof AddColumnChange)
            {
                AddColumnChange addColumnChange = (AddColumnChange)change;

                if (addColumnChange.getNewColumn().isAutoIncrement())
                {
                    createAutoIncrementSequence(addColumnChange.getChangedTable(),
                                                addColumnChange.getNewColumn());
                }
            }
        }

        print("ALTER ");
View Full Code Here

        {
            TableChange change = (TableChange)changeIt.next();

            if (change instanceof AddColumnChange)
            {
                AddColumnChange addColumnChange = (AddColumnChange)change;

                // Sybase can only add not insert columns
                if (addColumnChange.isAtEnd())
                {
                    processChange(currentModel, desiredModel, addColumnChange);
                    changeIt.remove();
                }
            }
View Full Code Here

        {
            TableChange change = (TableChange)changeIt.next();

            if (change instanceof AddColumnChange)
            {
                AddColumnChange addColumnChange = (AddColumnChange)change;

                // Derby can only add not insert columns, and the columns
                // cannot be identity columns
                if (addColumnChange.isAtEnd() && !addColumnChange.getNewColumn().isAutoIncrement())
                {
                    processChange(currentModel, desiredModel, addColumnChange);
                    changeIt.remove();
                }
            }
View Full Code Here

                changeIt.remove();
            }
        }
        for (Iterator changeIt = addColumnChanges.iterator(); changeIt.hasNext();)
        {
            AddColumnChange addColumnChange = (AddColumnChange)changeIt.next();

            processChange(currentModel, desiredModel, addColumnChange);
            changeIt.remove();
        }
View Full Code Here

        {
            TableChange change = (TableChange)changeIt.next();

            if (change instanceof AddColumnChange)
            {
                AddColumnChange addColumnChange = (AddColumnChange)change;

                if (addColumnChange.getNewColumn().isRequired() &&
                    (addColumnChange.getNewColumn().getDefaultValue() == null) &&
                    !addColumnChange.getNewColumn().isAutoIncrement())
                {
                    requiresFullRebuild = true;
                }
            }
        }
        if (!requiresFullRebuild)
        {
            processTableStructureChanges(currentModel, desiredModel, sourceTable, targetTable, parameters, changes);
        }

        if (!changes.isEmpty())
        {
            // we can only copy the data if no required columns without default value and
            // non-autoincrement have been added
            boolean canMigrateData = true;

            for (Iterator it = changes.iterator(); canMigrateData && it.hasNext();)
            {
                TableChange change = (TableChange)it.next();

                if (change instanceof AddColumnChange)
                {
                    AddColumnChange addColumnChange = (AddColumnChange)change;

                    if (addColumnChange.getNewColumn().isRequired() &&
                        !addColumnChange.getNewColumn().isAutoIncrement() &&
                        (addColumnChange.getNewColumn().getDefaultValue() == null))
                    {
                        _log.warn("Data cannot be retained in table " + change.getChangedTable().getName() +
                                  " because of the addition of the required column " + addColumnChange.getNewColumn().getName());
                        canMigrateData = false;
                    }
                }
            }
View Full Code Here

        {
            TableChange change = (TableChange)changeIt.next();

            if (change instanceof AddColumnChange)
            {
                AddColumnChange addColumnChange = (AddColumnChange)change;

                // Oracle can only add not insert columns
                // Also, we cannot add NOT NULL columns unless they have a default value
                if (!addColumnChange.isAtEnd() ||
                    (addColumnChange.getNewColumn().isRequired() && (addColumnChange.getNewColumn().getDefaultValue() == null)))
                {
                    // we need to rebuild the full table
                    return;
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.ddlutils.alteration.AddColumnChange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.