2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 12:06:44 +00:00
InvenTree/src/backend/InvenTree/users/migrations/0011_auto_20240523_1640.py
Oliver 0c56bd8dfa
Handle exception on migration (#7322)
* Handle exception on migration

* Make migration non-atomic
2024-05-24 23:31:23 +10:00

32 lines
791 B
Python

# Generated by Django 4.2.12 on 2024-05-23 16:40
from importlib import import_module
from django.conf import settings
from django.db import migrations
def clear_sessions(apps, schema_editor):
"""Clear all user sessions."""
try:
engine = import_module(settings.SESSION_ENGINE)
engine.SessionStore.clear_expired()
print('Cleared all user sessions to deal with GHSA-2crp-q9pc-457j')
except Exception:
# Database may not be ready yet, so this does not matter anyhow
pass
class Migration(migrations.Migration):
atomic = False
dependencies = [
("users", "0010_alter_apitoken_key"),
]
operations = [
migrations.RunPython(
clear_sessions, reverse_code=migrations.RunPython.noop,
)
]