Recovering Deleted Maps or Layers

All commands in this document have to be run in the Database shell.

There is a cronjob in the backend that permanently deletes maps and layers that have been marked for deletion 60 days in the past. We communicated this time-frame as 30 days to end users, so that admins also can enjoy life and don't need to do everything yesterday. If maps are still in the database, they can still be recovered.

To check if the map is still in the database, you can search for the map name in the database:

SELECT name FROM maps WHERE name ILIKE '%<INSERT_NAME>%';

Note: the name has to be entered around two % characters.

Finding out id's of maps and layers

Search soft deleted maps

SELECT name, id FROM maps WHERE deletion_date IS NOT NULL;

Search soft deleted maps by name

SELECT name, id FROM maps WHERE name ILIKE '%<INSERT_NAME>%' AND deletion_date IS NOT NULL;

Note: the name has to be entered around two % characters.

The found id is defined here as <FOUND_ID>.

Search soft deleted layers by map_id

After getting the id, deleted layers can also be found by running the following command:

SELECT * FROM layers WHERE map_id=<FOUND_ID> AND marked_deleted IS NOT NULL;

Search soft deleted layers

SELECT * FROM layers WHERE marked_deleted IS NOT NULL;

Recovering deleted maps

START TRANSACTION;
UPDATE maps SET deletion_date=NULL WHERE id=<FOUND_ID>;
-- Assert that only the one map was affected:
SELECT * FROM maps WHERE deletion_date IS NULL AND id=<FOUND_ID>;
-- Remove " __DELETED" and timestamp from map name:
UPDATE maps SET name = TRIM(TRAILING FROM SPLIT_PART(name, ' __DELETED', 1)) WHERE id=<FOUND_ID>;
COMMIT;

Recovering deleted layers

START TRANSACTION;
UPDATE layers SET marked_deleted=NULL WHERE id=<FOUND_ID>;
-- Assert that only the one layer was affected:
SELECT * FROM layers WHERE id=<FOUND_ID>;
COMMIT;