fix: ensure migrations run automatically after restoring backups to prevent missing schema issues

This commit is contained in:
SergeantPanda 2026-05-23 21:25:44 -05:00
parent 5ea194059b
commit 92d3068be0
3 changed files with 10 additions and 3 deletions

View file

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- **Restoring a backup from an older version left the database with missing schema.** The restore task ran `pg_restore` which replaced the entire database (including the `django_migrations` table) but did not run migrations afterward. If the backup predated a schema migration, the restored database was missing tables and columns added by those migrations, causing 500 errors on every API call. `migrate --noinput` now runs automatically after every restore. The success notification also now recommends a restart to clear stale service state.
## [0.25.1] - 2026-05-23
### Fixed

View file

@ -1,6 +1,7 @@
import logging
import traceback
from celery import shared_task
from django.core.management import call_command
from . import services
@ -61,6 +62,8 @@ def restore_backup_task(self, filename: str):
backup_file = backup_dir / filename
logger.info(f"[RESTORE] Backup file path: {backup_file}")
services.restore_backup(backup_file)
logger.info(f"[RESTORE] Running migrations after restore...")
call_command('migrate', '--noinput', verbosity=1)
logger.info(f"[RESTORE] Task {self.request.id} completed successfully")
return {
"status": "completed",

View file

@ -439,12 +439,12 @@ export default function BackupManager() {
try {
await API.restoreBackup(selectedBackup.name);
notifications.show({
title: 'Success',
title: 'Restore Complete',
message:
'Backup restored successfully. You may need to refresh the page.',
'Backup restored successfully. A restart is recommended to ensure all services are running against the restored data.',
color: 'green',
});
setTimeout(() => window.location.reload(), 2000);
setTimeout(() => window.location.reload(), 4000);
} catch (error) {
notifications.show({
title: 'Error',