Created
July 19, 2020 10:26
-
-
Save hkakutalua/be54c0867a0d284cf5be7e06936d3d52 to your computer and use it in GitHub Desktop.
PostgresDbCleanerExtension loadTablesToClean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Throws(SQLException::class) | |
private fun loadTablesToClean(connection: Connection): List<TableData> { | |
val databaseMetaData = connection.metaData | |
val resultSet = databaseMetaData.getTables( | |
connection.catalog, null, null, arrayOf("TABLE")) | |
val tablesToClean = mutableListOf<TableData>() | |
while (resultSet.next()) { | |
val table = TableData( | |
schema = resultSet.getString("TABLE_SCHEM"), | |
name = resultSet.getString("TABLE_NAME") | |
) | |
if (!TABLES_TO_IGNORE.contains(table)) { | |
tablesToClean.add(table) | |
} | |
} | |
return tablesToClean | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment