Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Jun 17, 2024
1 parent 52fac6e commit a55b3f2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions api/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import base64
import json
import logging
import secrets
from typing import Optional

Expand Down Expand Up @@ -560,16 +561,21 @@ def db_migrate():
lock = redis_client.lock(name='db_upgrade_lock', timeout=60)
if lock.acquire(blocking=False):
try:
import flask_migrate
click.echo(click.style('Start database migration.', fg='green'))

# run db migration
import flask_migrate
flask_migrate.upgrade()

click.echo(click.style('Database migration successful!', fg='green'))

except Exception as e:
logging.exception(f'Database migration failed, error: {e}')
finally:
lock.release()
else:
click.echo('Database migration skipped')


def register_commands(app):
app.cli.add_command(reset_password)
app.cli.add_command(reset_email)
Expand Down

0 comments on commit a55b3f2

Please sign in to comment.