Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/org/maproulette/models/dal/TaskDAL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ class TaskDAL @Inject() (
INSERT INTO tasks AS t (name, parent_id, status, instruction, priority, geojson, location, geom, cooperative_work_json)
SELECT name, {parentId}, 0, instruction, priority, geojson, ST_Centroid(geom), geom, cooperative_work
FROM input WHERE geom IS NOT NULL
ON CONFLICT (parent_id, lower(name)) DO UPDATE SET
ON CONFLICT (parent_id, md5(lower(name))) DO UPDATE SET
name = EXCLUDED.name, instruction = EXCLUDED.instruction, priority = EXCLUDED.priority,
changeset_id = -1, geojson = EXCLUDED.geojson,
cooperative_work_json = EXCLUDED.cooperative_work_json,
Expand Down
20 changes: 20 additions & 0 deletions conf/evolutions/default/132.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --- MapRoulette Scheme

# --- !Ups

-- Hash the task 'name' (unique key) to ensure indexed values are below the btree size
-- entry limit. Prod already has this index (created by hand at some point?) so this
-- is meant to be a no-op if this index already exists with the correct type.
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_indexes
WHERE indexname = 'idx_tasks_parent_id_name' AND indexdef LIKE '%md5(lower(%'
) THEN
DROP INDEX IF EXISTS idx_tasks_parent_id_name;;
CREATE UNIQUE INDEX idx_tasks_parent_id_name ON tasks (parent_id, md5(lower(name)));;
END IF;;
END
$$;;

# --- !Downs
Loading