Skip to content

Commit 82b54cb

Browse files
committed
Create index manually instead of from ogr2ogr
Because ogr2ogr sets the index name which leads to name clashes on update. If we let PostgreSQL choose the name we don't have this problem.
1 parent bb7ed85 commit 82b54cb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

themes/external/download-and-import.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,18 @@ import() {
6161
local file="$3"
6262
local inlayer="$4"
6363

64+
# Spatial index is created manually after import, because otherwise
65+
# the index names generated by ogr2ogr clash with the preexisting index.
66+
6467
ogr2ogr -f PostgreSQL "PG:dbname=$db" -overwrite -nln "${layer}_new" \
6568
-lco GEOMETRY_NAME=geom \
6669
-lco FID=id \
70+
-lco SPATIAL_INDEX=NONE \
6771
-sql 'select "_ogr_geometry_" from '"$inlayer" \
6872
"/vsizip/$file.zip/$file"
6973

7074
psql --quiet -d "$DB" -c "ANALYZE ${layer}_new;"
75+
psql --quiet -d "$DB" -c "CREATE INDEX ON ${layer}_new USING GIST (geom);"
7176
psql --quiet -d "$DB" -c "BEGIN; DROP TABLE IF EXISTS $layer; ALTER TABLE ${layer}_new RENAME TO $layer; COMMIT;"
7277
}
7378

0 commit comments

Comments
 (0)