Skip to content

Instantly share code, notes, and snippets.

@rixx
Created February 3, 2026 08:50
Show Gist options
  • Select an option

  • Save rixx/cd06dab05d3ae34bb6c81cc07be3cf4d to your computer and use it in GitHub Desktop.

Select an option

Save rixx/cd06dab05d3ae34bb6c81cc07be3cf4d to your computer and use it in GitHub Desktop.
pretalx ActivityLog legacy data migration

pretalx ActivityLog data migration

The ActivityLog table stores all data concerning user action logging – anything that looks like “The submission was updated.” etc.

The data format was changed to a proper JSON field for the v2025.2.0 release. In the v2026.1.0 release, we are dropping the old data field that contained JSON data in a text field.

There is not a lot of relevant data in the legacy field, as the data format was changed when we introduced the new field. As migrating the legacy data from the old field to the new field may take a long time, depending on the amount of data on your instance, we decided against running this as a mandatory migration. If you do want to retain the old data, however, this is how you can do it:

CAUTION: YOU MUST FOLLOW THIS GUIDE BEFORE UPGRADING TO v2026.1.0!

Open a Python shell in your pretalx installation by running python manage.py shell --unsafe-disable-scopes in your production environment.

Make sure you are in the right environment by listing the events available:

>>> print(Event.objects.all().values_list("slug", flat=True)

If the result matches your existing events, you are in the correct shell. Then copy the following code into the shell:

import json
from pretalx.common.models import ActivityLog

def migrate_legacy_data(batch_size=1000):
    logs = list(
        ActivityLog.objects.filter(legacy_data__isnull=False).exclude(legacy_data="")[
            :batch_size
        ]
    )
    to_update = []
    for log in logs:
        try:
            log.data = json.loads(log.legacy_data)
        except json.JSONDecodeError:
            log.data = {"_raw": log.legacy_data}
        log.legacy_data = None
        to_update.append(log)
    if to_update:
        ActivityLog.objects.bulk_update(to_update, ["data", "legacy_data"])
        print(f"Updated {len(to_update)} entries.")
    else:
        print("No entries to update.")
    remaining = (
        ActivityLog.objects.filter(legacy_data__isnull=False)
        .exclude(legacy_data="")
        .count()
    )
    print(f"Remaining entries with legacy_data: {remaining}")
    return remaining

Now you can repeatedly run migrate_legacy_data() until it reports that all data was migrated. You may also call migrate_legacy_data(batch_size=2000) for example, to process larger amounts at the same time. We recommend you increase the batch size slowly to make sure that your server can keep pace.

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