boolean equivalentForeignKeyExistsInDatabase(TableInformation tableInformation, String referencingColumn, String referencedTable) {
		return StreamSupport.stream( tableInformation.getForeignKeys().spliterator(), false )
				.flatMap( foreignKeyInformation -> StreamSupport.stream( foreignKeyInformation.getColumnReferenceMappings().spliterator(), false ) )
				.anyMatch( columnReferenceMapping -> {
			final ColumnInformation referencingColumnMetadata = columnReferenceMapping.getReferencingColumnMetadata();
			final ColumnInformation referencedColumnMetadata = columnReferenceMapping.getReferencedColumnMetadata();
			final String existingReferencingColumn = referencingColumnMetadata.getColumnIdentifier().getText();
			final String existingReferencedTable =
					referencedColumnMetadata.getContainingTableInformation().getName().getTableName().getCanonicalName();
			return referencingColumn.equalsIgnoreCase( existingReferencingColumn )
				&& referencedTable.equalsIgnoreCase( existingReferencedTable );
		} );
	}
@Test
    @TestForIssue(jiraKey = "HHH-13779")
    public void testForeignKeyPreExistenceDetectionIgnoresCaseForTableAndColumnName() {
        final AbstractSchemaMigrator schemaMigrator = new AbstractSchemaMigrator(null, null) {
            @Override
            protected NameSpaceTablesInformation performTablesMigration(Metadata metadata,
					DatabaseInformation existingDatabase, ExecutionOptions options,ContributableMatcher contributableInclusionFilter, Dialect dialect,
					Formatter formatter, Set<String> exportIdentifiers, boolean tryToCreateCatalogs,
					boolean tryToCreateSchemas, Set<Identifier> exportedCatalogs, Namespace namespace,
					SqlStringGenerationContext sqlStringGenerationContext,
					GenerationTarget[] targets) { return null; }
        };

        final TableInformation existingTableInformation = mock(TableInformation.class);
        final ArrayList<ForeignKeyInformation.ColumnReferenceMapping> columnReferenceMappings = new ArrayList<>();

        final TableInformation destinationTableInformation = mock(TableInformation.class);
        doReturn(new QualifiedTableName(toIdentifier("catalog"), toIdentifier("schema"),
                toIdentifier("referenced_table"))) // Table name is lower case
                .when(destinationTableInformation).getName();
        columnReferenceMappings.add(new ForeignKeyInformationImpl.ColumnReferenceMappingImpl(
                new ColumnInformationImpl(null, toIdentifier("referencing_column"), // column name is lower case
                        0, "typeName", 255, 0, TruthValue.TRUE),
                new ColumnInformationImpl(destinationTableInformation, null, 1, "typeName", 0, 0, TruthValue.TRUE)));
        doReturn(singletonList(new ForeignKeyInformationImpl(toIdentifier("FKp8mpamfw2inhj88hwhty1eipm"), columnReferenceMappings)))
                .when(existingTableInformation).getForeignKeys();

        final boolean existInDatabase = schemaMigrator.equivalentForeignKeyExistsInDatabase(
                existingTableInformation,
                "REFERENCING_COLUMN", "REFERENCED_TABLE"); // Table and column names are UPPER-case here, to prove the test

        assertThat("Expected ForeignKey pre-existence check to be case-insensitive",
                existInDatabase,
                is(true));
    }