@@ -140,7 +140,7 @@ def get_metadata(cls) -> sqlalchemy.MetaData:
140140 import sqlalchemy .ext .asyncio
141141 import sqlalchemy .orm
142142 from alembic .runtime .migration import MigrationContext
143- from alembic .script .base import Script
143+ from alembic .script .base import Script
144144
145145 from reflex .utils .compat import sqlmodel , sqlmodel_field_has_primary_key
146146
@@ -151,40 +151,39 @@ def get_metadata(cls) -> sqlalchemy.MetaData:
151151 # Import AsyncSession _after_ reflex.utils.compat
152152 from sqlmodel .ext .asyncio .session import AsyncSession
153153
154- def format_revision (
155- rev : Script ,
156- current_rev : str | None ,
157- current_reached_ref : list [bool ],
158- ) -> str :
159- """Format a single revision for display.
160-
161- Args:
162- rev: The alembic script object
163- current_rev: The currently applied revision ID
164- current_reached_ref: Mutable reference to track if we've reached current revision
165-
166- Returns:
167- Formatted string for display
168- """
169- current = rev .revision
170- message = rev .doc
171-
172- # Determine if this migration is applied
173- if current_rev is None :
174- is_applied = False
175- elif current == current_rev :
176- is_applied = True
177- current_reached_ref [0 ] = True
178- else :
179- is_applied = not current_reached_ref [0 ]
180-
181- # Show checkmark or X with colors
182- status_icon = "[green]✓[/green]" if is_applied else "[red]✗[/red]"
183- head_marker = " (head)" if rev .is_head else ""
184-
185- # Format output with message
186- return f" [{ status_icon } ] { current } { head_marker } , { message } "
154+ def format_revision (
155+ rev : Script ,
156+ current_rev : str | None ,
157+ current_reached_ref : list [bool ],
158+ ) -> str :
159+ """Format a single revision for display.
187160
161+ Args:
162+ rev: The alembic script object
163+ current_rev: The currently applied revision ID
164+ current_reached_ref: Mutable reference to track if we've reached current revision
165+
166+ Returns:
167+ Formatted string for display
168+ """
169+ current = rev .revision
170+ message = rev .doc
171+
172+ # Determine if this migration is applied
173+ if current_rev is None :
174+ is_applied = False
175+ elif current == current_rev :
176+ is_applied = True
177+ current_reached_ref [0 ] = True
178+ else :
179+ is_applied = not current_reached_ref [0 ]
180+
181+ # Show checkmark or X with colors
182+ status_icon = "[green]✓[/green]" if is_applied else "[red]✗[/red]"
183+ head_marker = " (head)" if rev .is_head else ""
184+
185+ # Format output with message
186+ return f" [{ status_icon } ] { current } { head_marker } , { message } "
188187
189188 def _safe_db_url_for_logging (url : str ) -> str :
190189 """Remove username and password from the database URL for logging.
@@ -429,25 +428,25 @@ def alembic_init(cls):
429428 )
430429
431430 @classmethod
432- def get_migration_history (cls ):
433- """Get migration history with current database state.
431+ def get_migration_history (cls ):
432+ """Get migration history with current database state.
434433
435- Returns:
436- tuple: (current_revision, revisions_list) where revisions_list is in chronological order
437- """
438- # Get current revision from database
439- with cls .get_db_engine ().connect () as connection :
440- context = MigrationContext .configure (connection )
441- current_rev = context .get_current_revision ()
434+ Returns:
435+ tuple: (current_revision, revisions_list) where revisions_list is in chronological order
436+ """
437+ # Get current revision from database
438+ with cls .get_db_engine ().connect () as connection :
439+ context = MigrationContext .configure (connection )
440+ current_rev = context .get_current_revision ()
442441
443- # Get all revisions from base to head
444- _ , script_dir = cls ._alembic_config ()
445- revisions = list (script_dir .walk_revisions ())
446- revisions .reverse () # Reverse to get chronological order (base first)
442+ # Get all revisions from base to head
443+ _ , script_dir = cls ._alembic_config ()
444+ revisions = list (script_dir .walk_revisions ())
445+ revisions .reverse () # Reverse to get chronological order (base first)
447446
448- return current_rev , revisions
447+ return current_rev , revisions
449448
450- @classmethod
449+ @classmethod
451450 def alembic_autogenerate (
452451 cls ,
453452 connection : sqlalchemy .engine .Connection ,
0 commit comments