Handle exception on migration (#7322)

* Handle exception on migration

* Make migration non-atomic
This commit is contained in:
Oliver 2024-05-24 23:31:23 +10:00 committed by GitHub
parent 0e1b78d88b
commit 0c56bd8dfa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,12 +9,17 @@ from django.db import migrations
def clear_sessions(apps, schema_editor): def clear_sessions(apps, schema_editor):
"""Clear all user sessions.""" """Clear all user sessions."""
try:
engine = import_module(settings.SESSION_ENGINE) engine = import_module(settings.SESSION_ENGINE)
engine.SessionStore.clear_expired() engine.SessionStore.clear_expired()
print('Cleared all user sessions to deal with GHSA-2crp-q9pc-457j') 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): class Migration(migrations.Migration):
atomic = False
dependencies = [ dependencies = [
("users", "0010_alter_apitoken_key"), ("users", "0010_alter_apitoken_key"),
] ]