     PERFORM UpdateGeometrySRID($7, $1, $2, $4);
   END IF;
 
-  IF idx_name IS NOT NULL
-  THEN
+  IF idx_name IS NOT NULL THEN
     -- recreate spatial index again
-    IF $3 < 3
-    THEN
-      EXECUTE format('CREATE INDEX %I ON %I.%I USING GIST (%I)', idx_name, $7, $1, $2);
-    ELSE
-      EXECUTE format('CREATE INDEX %I ON %I.%I USING GIST (%I gist_geometry_ops_nd )', idx_name, $7, $1, $2);
-    END IF;
+    EXECUTE format('CREATE INDEX %I ON %I.%I USING GIST (%I %I)', idx_name, $7, $1, $2, opclass_param);
   END IF;
 END;
 $$

  ) RETURNS SETOF VOID AS $$
DECLARE
  is_set_srs_info INTEGER;
  path_setting TEXT;
BEGIN
  -- set search_path for this session
  path_setting := current_setting('search_path');
  PERFORM set_config('search_path', $4 || ',public', true);

  -- check if user selected valid srid
  -- will raise an exception if not
  PERFORM citydb_pkg.check_srid($1);

BEGIN
  SELECT srid INTO schema_srid FROM spatial_ref_sys WHERE srid = $1;

  IF schema_srid IS NULL THEN
    RAISE EXCEPTION 'Table spatial_ref_sys does not contain the SRID %. Insert commands for missing SRIDs can be found at spatialreference.org', srsno;
    RETURN 'SRID not ok';
  END IF;
