Skip to content

Instantly share code, notes, and snippets.

@t-book
Last active December 2, 2019 15:02
Show Gist options
  • Save t-book/14bc849ad9567ca28a24c122d52ff77d to your computer and use it in GitHub Desktop.
Save t-book/14bc849ad9567ca28a24c122d52ff77d to your computer and use it in GitHub Desktop.
#!/bin/bash
sudo -u postgres psql -d geonode -c "UPDATE base_resourcebase SET thumbnail_url = replace(thumbnail_url, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE maps_maplayer SET ows_url = replace(ows_url, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE maps_maplayer SET layer_params = replace(layer_params, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE maps_maplayer SET source_params = replace(source_params, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE maps_mapsnapshot SET config = replace(config, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE base_resourcebase SET supplemental_information = replace(supplemental_information, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE base_resourcebase SET csw_anytext = replace(csw_anytext, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE django_site SET domain = replace(domain, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE layers_style SET sld_url = replace(sld_url, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE base_resourcebase SET metadata_xml = replace(metadata_xml, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE base_link SET url = replace(url, '$1', '$2')"
@frafra
Copy link

frafra commented Dec 2, 2019

This is what I did, just looking at a simple dump, but it could be incomplete:

begin;
\set old https://geodata-test.nina.no:8080
\set new https://geodata.nina.no
update base_link
   set url           = replace(url,           :'old', :'new');
update base_resourcebase
   set csw_anytext   = replace(csw_anytext,   :'old', :'new'),
       thumbnail_url = replace(thumbnail_url, :'old', :'new');
commit;

updatelayers does not seem to be related to that. I did not tried fixsitename.

An alternative solution would be to use sed on a dump.

@t-book
Copy link
Author

t-book commented Dec 2, 2019

@fra_fra nice, thanks. To dump the data and just use sed worked for me as well in several instances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment