The first step is to check the validity of input geometries. PostGIS will refuse to convert invalid geometries to topology elements, so it's very important to fix them or filter them out. We will use the ST_IsValidReason and ST_IsValid functions that we learned in Chapter 1, Importing Spatial Data:
SELECT ST_IsValidReason(geom) FROM countries WHERE ST_IsValid(geom) = FALSE;
Luckily, in this case the query returned 0 rows, meaning that all geometries are valid, so we can proceed to the next step.
It may happen that invalid geometries sneak into some revised version of Natural Earth, in which case the query will return a non-zero result. In that case, the invalid geometries must be repaired with the tools outlined in Chapter 1, Importing Spatial Data, or deleted before proceeding.