Java Code Examples for org.apache.ddlutils.model.Column#isPrimaryKey()

The following examples show how to use org.apache.ddlutils.model.Column#isPrimaryKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlBuilder.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
     * Outputs the DDL for the specified column.
     * 
     * @param table  The table containing the column
     * @param column The column
     */
    protected void writeColumn(Table table, Column column) throws IOException
    {
        //see comments in columnsDiffer about null/"" defaults
        printIdentifier(getColumnName(column));
        print(" ");
        print(getSqlType(column));
        writeColumnDefaultValueStmt(table, column);
        if (column.isRequired())
        {
            print(" ");
            writeColumnNotNullableStmt();
        }
        else if (getPlatformInfo().isNullAsDefaultValueRequired() &&
                 getPlatformInfo().hasNullDefault(column.getTypeCode()))
        {
            print(" ");
            writeColumnNullableStmt();
        }
// GemStone changes BEGIN
        if (column.isAutoIncrement() &&
            !getPlatformInfo().isDefaultValueUsedForIdentitySpec() &&
            !(getPlatform().isAddIdentityUsingAlterTableOn() &&
                getPlatformInfo().isAddingIdentityUsingAlterTableSupported()))
        /* (original code)
        if (column.isAutoIncrement() && !getPlatformInfo().isDefaultValueUsedForIdentitySpec())
        */
// GemStone changes END
        {
            if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported() && !column.isPrimaryKey())
            {
                throw new ModelException("Column "+column.getName()+" in table "+table.getQualifiedName()+" is auto-incrementing but not a primary key column, which is not supported by the platform");
            }
            print(" ");
            writeColumnAutoIncrementStmt(table, column);
        }
    }
 
Example 2
Source File: Oracle8Platform.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected TableDefinitionChangesPredicate getTableDefinitionChangesPredicate()
{
    // While Oracle has an ALTER TABLE MODIFY statement, it is somewhat limited
    // esp. if there is data in the table, so we don't use it
    return new DefaultTableDefinitionChangesPredicate()
    {
        protected boolean isSupported(Table intermediateTable, TableChange change)
        {
            if ((change instanceof AddPrimaryKeyChange) ||
                (change instanceof RemovePrimaryKeyChange))
            {
                return true;
            }
            else if (change instanceof RemoveColumnChange)
            {
                // TODO: for now we trigger recreating the table, but ideally we should simply add the necessary pk changes
                RemoveColumnChange removeColumnChange = (RemoveColumnChange)change;
                Column             column             = intermediateTable.findColumn(removeColumnChange.getChangedColumn(), isDelimitedIdentifierModeOn());

                return !column.isPrimaryKey();
            }
            else 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
                return addColumnChange.isAtEnd() &&
                       (!addColumnChange.getNewColumn().isRequired() || (addColumnChange.getNewColumn().getDefaultValue() != null));
            }
            else
            {
                return false;
            }
        }
    };
}
 
Example 3
Source File: MSSqlModelComparator.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected List checkForPrimaryKeyChanges(Database sourceModel,
                                         Table    sourceTable,
                                         Database intermediateModel,
                                         Table    intermediateTable,
                                         Database targetModel,
                                         Table    targetTable)
{
    List changes = super.checkForPrimaryKeyChanges(sourceModel, sourceTable, intermediateModel, intermediateTable, targetModel, targetTable);

    // now we add pk changes if one of the pk columns was changed
    // we only need to do this if there is no other pk change (which can only be a remove or add change or both)
    if (changes.isEmpty())
    {
        List columns = getRelevantChangedColumns(sourceTable, targetTable);

        for (Iterator it = columns.iterator(); it.hasNext();)
        {
            Column targetColumn = (Column)it.next();

            if (targetColumn.isPrimaryKey())
            {
                changes.add(new RemovePrimaryKeyChange(sourceTable.getName()));
                changes.add(new AddPrimaryKeyChange(sourceTable.getName(), sourceTable.getPrimaryKeyColumnNames()));
                break;
            }
        }
    }
    return changes;
}
 
Example 4
Source File: HsqlDbBuilder.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void writeColumn(Table table, Column column) throws IOException
{
    //see comments in columnsDiffer about null/"" defaults
    printIdentifier(getColumnName(column));
    print(" ");
    print(getSqlType(column));
    if (column.isAutoIncrement())
    {
        if (!column.isPrimaryKey())
        {
            throw new ModelException("Column "+column.getName()+" in table "+table.getName()+" is auto-incrementing but not a primary key column, which is not supported by the platform");
        }
        print(" ");
        writeColumnAutoIncrementStmt(table, column);
    }
    else
    {
        writeColumnDefaultValueStmt(table, column);
    }
    if (column.isRequired())
    {
        print(" ");
        writeColumnNotNullableStmt();
    }
    else if (getPlatformInfo().isNullAsDefaultValueRequired() &&
             getPlatformInfo().hasNullDefault(column.getTypeCode()))
    {
        print(" ");
        writeColumnNullableStmt();
    }
}
 
Example 5
Source File: HsqlDbPlatform.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected TableDefinitionChangesPredicate getTableDefinitionChangesPredicate()
{
    return new DefaultTableDefinitionChangesPredicate()
    {
        protected boolean isSupported(Table intermediateTable, TableChange change)
        {
            if (change instanceof RemoveColumnChange)
            {
                Column column = intermediateTable.findColumn(((RemoveColumnChange)change).getChangedColumn(),
                                                             isDelimitedIdentifierModeOn());

                // HsqlDb can only drop columns that are not part of a primary key
                return !column.isPrimaryKey();
            }
            else if (change instanceof AddColumnChange)
            {
                AddColumnChange addColumnChange = (AddColumnChange)change; 

                // adding IDENTITY columns is not supported without a table rebuild because they have to
                // be PK columns, but we add them to the PK later
                return addColumnChange.isAtEnd() &&
                       (!addColumnChange.getNewColumn().isRequired() ||
                        (addColumnChange.getNewColumn().getDefaultValue() != null));
            }
            else if (change instanceof AddPrimaryKeyChange)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    };
}
 
Example 6
Source File: JdbcModelReader.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to remove the internal index for the given foreign key.
 * 
 * @param metaData The database meta data
 * @param table    The table where the table is defined
 * @param fk       The foreign key
 */
protected void removeInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table, ForeignKey fk) throws SQLException
{
    List    columnNames  = new ArrayList();
    boolean mustBeUnique = !getPlatformInfo().isSystemForeignKeyIndicesAlwaysNonUnique();

    for (int columnIdx = 0; columnIdx < fk.getReferenceCount(); columnIdx++)
    {
        String name        = fk.getReference(columnIdx).getLocalColumnName();
        Column localColumn = table.findColumn(name,
                                              getPlatform().isDelimitedIdentifierModeOn());

        if (mustBeUnique && !localColumn.isPrimaryKey())
        {
            mustBeUnique = false;
        }
        columnNames.add(name);
    }

    for (int indexIdx = 0; indexIdx < table.getIndexCount();)
    {
        Index index = table.getIndex(indexIdx);

        if ((!mustBeUnique || index.isUnique()) && matches(index, columnNames) && 
            isInternalForeignKeyIndex(metaData, table, fk, index))
        {
            fk.setAutoIndexPresent(true);
            table.removeIndex(indexIdx);
        }
        else
        {
            indexIdx++;
        }
    }
}
 
Example 7
Source File: DataDtdWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the DTD attribute entry for the given column.
 * 
 * @param column The column
 * @param writer The writer to write the attribute entry to
 */
private void writeColumnAttributeEntry(Column column, PrintWriter writer) throws IOException
{
    writer.print("    <!--");
    if (column.isPrimaryKey())
    {
        writer.print(" primary key,");
    }
    if (column.isAutoIncrement())
    {
        writer.print(" auto increment,");
    }
    writer.print(" JDBC type: "+column.getType());
    if ((column.getSize() != null) && (column.getSize().length() > 0))
    {
        writer.print("("+column.getSize()+")");
    }
    writer.println(" -->");
    writer.print("    "+column.getName()+" CDATA ");
    if ((column.getDefaultValue() != null) && (column.getDefaultValue().length() > 0))
    {
        writer.println("\"" + column.getDefaultValue() + "\"");
    }
    else
    {
        writer.println(column.isRequired() ? "#REQUIRED" : "#IMPLIED");
    }
}
 
Example 8
Source File: SqlServerDialect.java    From DataLink with Apache License 2.0 5 votes vote down vote up
@Override
public boolean hasAutoIncrementNotKeyColumns(String schemaName, String tableName) {
    Table table = findTable(schemaName, tableName);
    Column[] columns = table.getAutoIncrementColumns();
    boolean flag = false;
    if (columns != null) {
        for (Column column : columns) {
            if (!column.isPrimaryKey()) {
                flag = true;
                break;
            }
        }
    }
    return flag;
}
 
Example 9
Source File: SqlBuilder.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
     * Outputs the DDL for the specified column.
     * 
     * @param table  The table containing the column
     * @param column The column
     */
    protected void writeColumn(Table table, Column column) throws IOException
    {
        //see comments in columnsDiffer about null/"" defaults
        printIdentifier(getColumnName(column));
        print(" ");
        print(getSqlType(column));
        writeColumnDefaultValueStmt(table, column);
        if (column.isRequired())
        {
            print(" ");
            writeColumnNotNullableStmt();
        }
        else if (getPlatformInfo().isNullAsDefaultValueRequired() &&
                 getPlatformInfo().hasNullDefault(column.getTypeCode()))
        {
            print(" ");
            writeColumnNullableStmt();
        }
// GemStone changes BEGIN
        if (column.isAutoIncrement() &&
            !getPlatformInfo().isDefaultValueUsedForIdentitySpec() &&
            !(getPlatform().isAddIdentityUsingAlterTableOn() &&
                getPlatformInfo().isAddingIdentityUsingAlterTableSupported()))
        /* (original code)
        if (column.isAutoIncrement() && !getPlatformInfo().isDefaultValueUsedForIdentitySpec())
        */
// GemStone changes END
        {
            if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported() && !column.isPrimaryKey())
            {
                throw new ModelException("Column "+column.getName()+" in table "+table.getQualifiedName()+" is auto-incrementing but not a primary key column, which is not supported by the platform");
            }
            print(" ");
            writeColumnAutoIncrementStmt(table, column);
        }
    }
 
Example 10
Source File: Oracle8Platform.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected TableDefinitionChangesPredicate getTableDefinitionChangesPredicate()
{
    // While Oracle has an ALTER TABLE MODIFY statement, it is somewhat limited
    // esp. if there is data in the table, so we don't use it
    return new DefaultTableDefinitionChangesPredicate()
    {
        protected boolean isSupported(Table intermediateTable, TableChange change)
        {
            if ((change instanceof AddPrimaryKeyChange) ||
                (change instanceof RemovePrimaryKeyChange))
            {
                return true;
            }
            else if (change instanceof RemoveColumnChange)
            {
                // TODO: for now we trigger recreating the table, but ideally we should simply add the necessary pk changes
                RemoveColumnChange removeColumnChange = (RemoveColumnChange)change;
                Column             column             = intermediateTable.findColumn(removeColumnChange.getChangedColumn(), isDelimitedIdentifierModeOn());

                return !column.isPrimaryKey();
            }
            else 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
                return addColumnChange.isAtEnd() &&
                       (!addColumnChange.getNewColumn().isRequired() || (addColumnChange.getNewColumn().getDefaultValue() != null));
            }
            else
            {
                return false;
            }
        }
    };
}
 
Example 11
Source File: MSSqlModelComparator.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected List checkForPrimaryKeyChanges(Database sourceModel,
                                         Table    sourceTable,
                                         Database intermediateModel,
                                         Table    intermediateTable,
                                         Database targetModel,
                                         Table    targetTable)
{
    List changes = super.checkForPrimaryKeyChanges(sourceModel, sourceTable, intermediateModel, intermediateTable, targetModel, targetTable);

    // now we add pk changes if one of the pk columns was changed
    // we only need to do this if there is no other pk change (which can only be a remove or add change or both)
    if (changes.isEmpty())
    {
        List columns = getRelevantChangedColumns(sourceTable, targetTable);

        for (Iterator it = columns.iterator(); it.hasNext();)
        {
            Column targetColumn = (Column)it.next();

            if (targetColumn.isPrimaryKey())
            {
                changes.add(new RemovePrimaryKeyChange(sourceTable.getName()));
                changes.add(new AddPrimaryKeyChange(sourceTable.getName(), sourceTable.getPrimaryKeyColumnNames()));
                break;
            }
        }
    }
    return changes;
}
 
Example 12
Source File: HsqlDbBuilder.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void writeColumn(Table table, Column column) throws IOException
{
    //see comments in columnsDiffer about null/"" defaults
    printIdentifier(getColumnName(column));
    print(" ");
    print(getSqlType(column));
    if (column.isAutoIncrement())
    {
        if (!column.isPrimaryKey())
        {
            throw new ModelException("Column "+column.getName()+" in table "+table.getName()+" is auto-incrementing but not a primary key column, which is not supported by the platform");
        }
        print(" ");
        writeColumnAutoIncrementStmt(table, column);
    }
    else
    {
        writeColumnDefaultValueStmt(table, column);
    }
    if (column.isRequired())
    {
        print(" ");
        writeColumnNotNullableStmt();
    }
    else if (getPlatformInfo().isNullAsDefaultValueRequired() &&
             getPlatformInfo().hasNullDefault(column.getTypeCode()))
    {
        print(" ");
        writeColumnNullableStmt();
    }
}
 
Example 13
Source File: HsqlDbPlatform.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected TableDefinitionChangesPredicate getTableDefinitionChangesPredicate()
{
    return new DefaultTableDefinitionChangesPredicate()
    {
        protected boolean isSupported(Table intermediateTable, TableChange change)
        {
            if (change instanceof RemoveColumnChange)
            {
                Column column = intermediateTable.findColumn(((RemoveColumnChange)change).getChangedColumn(),
                                                             isDelimitedIdentifierModeOn());

                // HsqlDb can only drop columns that are not part of a primary key
                return !column.isPrimaryKey();
            }
            else if (change instanceof AddColumnChange)
            {
                AddColumnChange addColumnChange = (AddColumnChange)change; 

                // adding IDENTITY columns is not supported without a table rebuild because they have to
                // be PK columns, but we add them to the PK later
                return addColumnChange.isAtEnd() &&
                       (!addColumnChange.getNewColumn().isRequired() ||
                        (addColumnChange.getNewColumn().getDefaultValue() != null));
            }
            else if (change instanceof AddPrimaryKeyChange)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    };
}
 
Example 14
Source File: JdbcModelReader.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to remove the internal index for the given foreign key.
 * 
 * @param metaData The database meta data
 * @param table    The table where the table is defined
 * @param fk       The foreign key
 */
protected void removeInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table, ForeignKey fk) throws SQLException
{
    List    columnNames  = new ArrayList();
    boolean mustBeUnique = !getPlatformInfo().isSystemForeignKeyIndicesAlwaysNonUnique();

    for (int columnIdx = 0; columnIdx < fk.getReferenceCount(); columnIdx++)
    {
        String name        = fk.getReference(columnIdx).getLocalColumnName();
        Column localColumn = table.findColumn(name,
                                              getPlatform().isDelimitedIdentifierModeOn());

        if (mustBeUnique && !localColumn.isPrimaryKey())
        {
            mustBeUnique = false;
        }
        columnNames.add(name);
    }

    for (int indexIdx = 0; indexIdx < table.getIndexCount();)
    {
        Index index = table.getIndex(indexIdx);

        if ((!mustBeUnique || index.isUnique()) && matches(index, columnNames) && 
            isInternalForeignKeyIndex(metaData, table, fk, index))
        {
            fk.setAutoIndexPresent(true);
            table.removeIndex(indexIdx);
        }
        else
        {
            indexIdx++;
        }
    }
}
 
Example 15
Source File: DataDtdWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the DTD attribute entry for the given column.
 * 
 * @param column The column
 * @param writer The writer to write the attribute entry to
 */
private void writeColumnAttributeEntry(Column column, PrintWriter writer) throws IOException
{
    writer.print("    <!--");
    if (column.isPrimaryKey())
    {
        writer.print(" primary key,");
    }
    if (column.isAutoIncrement())
    {
        writer.print(" auto increment,");
    }
    writer.print(" JDBC type: "+column.getType());
    if ((column.getSize() != null) && (column.getSize().length() > 0))
    {
        writer.print("("+column.getSize()+")");
    }
    writer.println(" -->");
    writer.print("    "+column.getName()+" CDATA ");
    if ((column.getDefaultValue() != null) && (column.getDefaultValue().length() > 0))
    {
        writer.println("\"" + column.getDefaultValue() + "\"");
    }
    else
    {
        writer.println(column.isRequired() ? "#REQUIRED" : "#IMPLIED");
    }
}
 
Example 16
Source File: TestAgainstLiveDatabaseBase.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a copy of the given model adjusted for type changes because of the native type mappings
 * which when read back from the database will map to different types.
 * 
 * @param sourceModel The source model
 * @return The adjusted model
 */
protected Database adjustModel(Database sourceModel)
{
    Database model = new CloneHelper().clone(sourceModel);

    for (int tableIdx = 0; tableIdx < model.getTableCount(); tableIdx++)
    {
        Table table = model.getTable(tableIdx);

        for (int columnIdx = 0; columnIdx < table.getColumnCount(); columnIdx++)
        {
            Column column     = table.getColumn(columnIdx);
            int    origType   = column.getTypeCode();
            int    targetType = getPlatformInfo().getTargetJdbcType(origType);

            // we adjust the column types if the native type would back-map to a
            // different jdbc type
            if (targetType != origType)
            {
                column.setTypeCode(targetType);
                // we should also adapt the default value
                if (column.getDefaultValue() != null)
                {
                    DefaultValueHelper helper = getPlatform().getSqlBuilder().getDefaultValueHelper();

                    column.setDefaultValue(helper.convert(column.getDefaultValue(), origType, targetType));
                }
            }
            // we also promote the default size if the column has no size
            // spec of its own
            if ((column.getSize() == null) && getPlatformInfo().hasSize(targetType))
            {
                Integer defaultSize = getPlatformInfo().getDefaultSize(targetType);

                if (defaultSize != null)
                {
                    column.setSize(defaultSize.toString());
                }
            }
            // finally the platform might return a synthetic default value if the column
            // is a primary key column
            if (getPlatformInfo().isSyntheticDefaultValueForRequiredReturned() &&
                (column.getDefaultValue() == null) && column.isRequired() && !column.isAutoIncrement())
            {
                switch (column.getTypeCode())
                {
                    case Types.TINYINT:
                    case Types.SMALLINT:
                    case Types.INTEGER:
                    case Types.BIGINT:
                        column.setDefaultValue("0");
                        break;
                    case Types.REAL:
                    case Types.FLOAT:
                    case Types.DOUBLE:
                        column.setDefaultValue("0.0");
                        break;
                    case Types.BIT:
                        column.setDefaultValue("false");
                        break;
                    default:
                        column.setDefaultValue("");
                        break;
                }
            }
            if (column.isPrimaryKey() && getPlatformInfo().isPrimaryKeyColumnAutomaticallyRequired())
            {
                column.setRequired(true);
            }
            if (column.isAutoIncrement() && getPlatformInfo().isIdentityColumnAutomaticallyRequired())
            {
                column.setRequired(true);
            }
        }
        // we also add the default names to foreign keys that are initially unnamed
        for (int fkIdx = 0; fkIdx < table.getForeignKeyCount(); fkIdx++)
        {
            ForeignKey fk = table.getForeignKey(fkIdx);

            if (fk.getName() == null)
            {
                fk.setName(getPlatform().getSqlBuilder().getForeignKeyName(table, fk));
            }
        }
    }
    return model;
}
 
Example 17
Source File: TestAgainstLiveDatabaseBase.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a copy of the given model adjusted for type changes because of the native type mappings
 * which when read back from the database will map to different types.
 * 
 * @param sourceModel The source model
 * @return The adjusted model
 */
protected Database adjustModel(Database sourceModel)
{
    Database model = new CloneHelper().clone(sourceModel);

    for (int tableIdx = 0; tableIdx < model.getTableCount(); tableIdx++)
    {
        Table table = model.getTable(tableIdx);

        for (int columnIdx = 0; columnIdx < table.getColumnCount(); columnIdx++)
        {
            Column column     = table.getColumn(columnIdx);
            int    origType   = column.getTypeCode();
            int    targetType = getPlatformInfo().getTargetJdbcType(origType);

            // we adjust the column types if the native type would back-map to a
            // different jdbc type
            if (targetType != origType)
            {
                column.setTypeCode(targetType);
                // we should also adapt the default value
                if (column.getDefaultValue() != null)
                {
                    DefaultValueHelper helper = getPlatform().getSqlBuilder().getDefaultValueHelper();

                    column.setDefaultValue(helper.convert(column.getDefaultValue(), origType, targetType));
                }
            }
            // we also promote the default size if the column has no size
            // spec of its own
            if ((column.getSize() == null) && getPlatformInfo().hasSize(targetType))
            {
                Integer defaultSize = getPlatformInfo().getDefaultSize(targetType);

                if (defaultSize != null)
                {
                    column.setSize(defaultSize.toString());
                }
            }
            // finally the platform might return a synthetic default value if the column
            // is a primary key column
            if (getPlatformInfo().isSyntheticDefaultValueForRequiredReturned() &&
                (column.getDefaultValue() == null) && column.isRequired() && !column.isAutoIncrement())
            {
                switch (column.getTypeCode())
                {
                    case Types.TINYINT:
                    case Types.SMALLINT:
                    case Types.INTEGER:
                    case Types.BIGINT:
                        column.setDefaultValue("0");
                        break;
                    case Types.REAL:
                    case Types.FLOAT:
                    case Types.DOUBLE:
                        column.setDefaultValue("0.0");
                        break;
                    case Types.BIT:
                        column.setDefaultValue("false");
                        break;
                    default:
                        column.setDefaultValue("");
                        break;
                }
            }
            if (column.isPrimaryKey() && getPlatformInfo().isPrimaryKeyColumnAutomaticallyRequired())
            {
                column.setRequired(true);
            }
            if (column.isAutoIncrement() && getPlatformInfo().isIdentityColumnAutomaticallyRequired())
            {
                column.setRequired(true);
            }
        }
        // we also add the default names to foreign keys that are initially unnamed
        for (int fkIdx = 0; fkIdx < table.getForeignKeyCount(); fkIdx++)
        {
            ForeignKey fk = table.getForeignKey(fkIdx);

            if (fk.getName() == null)
            {
                fk.setName(getPlatform().getSqlBuilder().getForeignKeyName(table, fk));
            }
        }
    }
    return model;
}