コード例 #1
0
  protected void writeForeignKey(
      DdlWrite write,
      String fkName,
      String tableName,
      String[] columns,
      String refTable,
      String[] refColumns,
      String indexName)
      throws IOException {

    tableName = lowerName(tableName);
    DdlBuffer fkeyBuffer = write.applyForeignKeys();
    alterTableAddForeignKey(fkeyBuffer, fkName, tableName, columns, refTable, refColumns);

    if (indexName != null) {
      // no matching unique constraint so add the index
      fkeyBuffer.append(platformDdl.createIndex(indexName, tableName, columns)).endOfStatement();
    }

    fkeyBuffer.end();

    write
        .rollbackForeignKeys()
        .append(platformDdl.alterTableDropForeignKey(tableName, fkName))
        .endOfStatement();

    if (indexName != null) {
      write
          .rollbackForeignKeys()
          .append(platformDdl.dropIndex(indexName, tableName))
          .endOfStatement();
    }

    write.rollbackForeignKeys().end();
  }
コード例 #2
0
  protected void alterColumnDropForeignKey(DdlWrite writer, AlterColumn alter) throws IOException {

    writer
        .apply()
        .append(
            platformDdl.alterTableDropForeignKey(alter.getTableName(), alter.getDropForeignKey()))
        .endOfStatement();
  }