@Override
  protected void addStoredFunction(DdlWrite writer, MTable table, HistoryTableUpdate update)
      throws IOException {

    String procedureName = procedureName(table.getName());
    String historyTable = historyTableName(table.getName());

    List<String> includedColumns = includedColumnNames(table);

    DdlBuffer apply = writer.applyHistory();

    if (update != null) {
      apply.append("-- Regenerated ").append(procedureName).newLine();
      apply.append("-- changes: ").append(update.description()).newLine();
    }

    addFunction(apply, procedureName, historyTable, includedColumns);

    if (update != null) {
      // put a reverted version into the rollback buffer
      update.toRevertedColumns(includedColumns);

      DdlBuffer rollback = writer.rollback();
      rollback.append("-- Revert regenerated ").append(procedureName).newLine();
      rollback.append("-- revert changes: ").append(update.description()).newLine();

      addFunction(rollback, procedureName, historyTable, includedColumns);
    }
  }
  /** Register the base table that we need to regenerate the history triggers on. */
  protected void regenerateHistoryTriggers(
      String baseTableName, HistoryTableUpdate.Change change, String column) {

    HistoryTableUpdate update = regenerateHistoryTriggers.get(baseTableName);
    if (update == null) {
      update = new HistoryTableUpdate(baseTableName);
      regenerateHistoryTriggers.put(baseTableName, update);
    }
    update.add(change, column);
  }