Пример #1
0
  /**
   * Outputs statements for dropping triggers.
   *
   * @param writer writer the output should be written to
   * @param oldSchema original schema
   * @param newSchema new schema
   * @param searchPathHelper search path helper
   */
  public static void dropTriggers(
      final PrintWriter writer,
      final PgSchema oldSchema,
      final PgSchema newSchema,
      final SearchPathHelper searchPathHelper) {
    for (final PgTable newTable : newSchema.getTables()) {
      final PgTable oldTable;

      if (oldSchema == null) {
        oldTable = null;
      } else {
        oldTable = oldSchema.getTable(newTable.getName());
      }

      // Drop triggers that no more exist or are modified
      for (final PgTrigger trigger : getDropTriggers(oldTable, newTable)) {
        searchPathHelper.outputSearchPath(writer);
        writer.println();
        writer.println(trigger.getDropSQL());
      }
    }
  }