Skip to content

Commit

Permalink
Clean up logging in syncdb and make sure to reset migration state
Browse files Browse the repository at this point in the history
  • Loading branch information
aloftus23 committed Nov 20, 2024
1 parent 5295728 commit 6711338
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend/src/xfd_django/xfd_api/tasks/run_syncdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ def apply_dynamic_migrations():
"""
connection.prepare_database() # Ensure the database is initialized
executor = MigrationExecutor(connection)
executor.loader.build_graph() # Load the migration graph

# Reset migration state to force detection
executor.loader.build_graph(reset=True)

# Detect unapplied migrations
targets = executor.loader.graph.leaf_nodes()
print(targets)
print(f"Detected migration targets: {targets}")
plan = executor.migration_plan(targets)
print(plan)
print(f"Migration plan: {plan}")

if not plan:
print("No migrations to apply.")
Expand Down

0 comments on commit 6711338

Please sign in to comment.