コード例 #1
0
  @Override
  public SqlStatement[] generateRollbackStatements(final Database database)
      throws RollbackImpossibleException {
    List<SqlStatement> result = new ArrayList<SqlStatement>();
    String permissionId =
        getPermissionForeignKey(database, getName(), getNamespace(), getTemplate());

    final DeleteDataChange removePerm = new DeleteDataChange();
    removePerm.setTableName("krim_perm_t");
    removePerm.setWhereClause(String.format("perm_id = '%s'", permissionId));

    for (AddPermissionAttribute attribute : attributes) {
      attribute.setPermissionId(permissionId);
      result.addAll(Arrays.asList(attribute.generateRollbackStatements(database)));
    }

    result.addAll(Arrays.asList(removePerm.generateStatements(database)));
    return result.toArray(new SqlStatement[result.size()]);
  }
コード例 #2
0
  /**
   * Generates the SQL statements required to run the change.
   *
   * @param database databasethe target {@link liquibase.database.Database} associated to this
   *     change's statements
   * @return an array of {@link String}s with the statements
   */
  public SqlStatement[] generateStatements(final Database database) {

    final List<SqlStatement> attributeStatements = new ArrayList<SqlStatement>();

    for (final AddPermissionAttribute attribute : getAttributes()) {
      for (final SqlStatement statement : attribute.generateStatements(database)) {
        attributeStatements.add(statement);
      }
    }

    return new SqlStatement[] {
      new CreatePermissionStatement(
          getTemplate(),
          getNamespace(),
          getName(),
          getDescription(),
          getActive(),
          attributeStatements)
    };
  }