Skip to content

Commit

Permalink
Handle exception on migration (#7322)
Browse files Browse the repository at this point in the history
* Handle exception on migration

* Make migration non-atomic
  • Loading branch information
SchrodingersGat authored May 24, 2024
1 parent 0e1b78d commit 0c56bd8
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
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"),
]
Expand Down

0 comments on commit 0c56bd8

Please sign in to comment.