From 0c56bd8dfaed1f0a5e2a75a02606aab62534ba56 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 24 May 2024 23:31:23 +1000 Subject: [PATCH] Handle exception on migration (#7322) * Handle exception on migration * Make migration non-atomic --- .../users/migrations/0011_auto_20240523_1640.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/backend/InvenTree/users/migrations/0011_auto_20240523_1640.py b/src/backend/InvenTree/users/migrations/0011_auto_20240523_1640.py index 1673fcc899..cdda226fe9 100644 --- a/src/backend/InvenTree/users/migrations/0011_auto_20240523_1640.py +++ b/src/backend/InvenTree/users/migrations/0011_auto_20240523_1640.py @@ -9,12 +9,17 @@ from django.db import migrations def clear_sessions(apps, schema_editor): """Clear all user sessions.""" - engine = import_module(settings.SESSION_ENGINE) - engine.SessionStore.clear_expired() - print('Cleared all user sessions to deal with GHSA-2crp-q9pc-457j') - + 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"), ]