Skip to content

Commit

Permalink
ignore version in pg_dump and throw warning
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Feb 11, 2024
1 parent 9b1ba7b commit b1facf6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cashu/core/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@ async def backup_database(db: Database, version: int = 0) -> str:
elif db.type in {POSTGRES, COCKROACH}:
filepath = f"{filepath}.dump"
logger.info(f"Creating {db.type} backup of {db.name} db to {filepath}")
os.system(f"pg_dump --dbname={db.db_location} --file={filepath}")
try:
os.system(f"pg_dump --dbname={db.db_location} --file={filepath}")
except Exception as e:
logger.error(
f"Error creating backup of {db.name} db: {e}. Run with"
" BACKUP_DB_MIGRATION=False to disable backups before database"
" migrations."
)
logger.warning("Trying pg_dump with option to ignore version mismatch")
os.system(
f"pg_dump --ignore-version --dbname={db.db_location} --file={filepath}"
)

return filepath

Expand Down

0 comments on commit b1facf6

Please sign in to comment.