Last active
October 10, 2023 13:36
-
-
Save quaxsze/790698bb08220a580cee43cce64fdfdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from udata.models import Dataset | |
from udata.app import create_app | |
def migrate(): | |
print('Processing resources.') | |
app = create_app() | |
with app.app_context(): | |
datasets = Dataset.objects(resources__url__contains='http://static').no_cache().timeout(False) | |
counter = 0 | |
for dataset in datasets: | |
for resource in dataset.resources: | |
if resource.url.startswith('http://static'): | |
resource.url = resource.url.replace('http://', 'https://') | |
counter += 1 | |
try: | |
dataset.save() | |
except Exception as e: | |
print(e) | |
pass | |
print(f'Completed migration on {counter} resources.') | |
if __name__ == "__main__": | |
migrate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment