Skip to content

Commit 9a4335f

Browse files
committed
Refactor column name to "alembic_head_revisions".
Renamed the "alembic_revision" column to "alembic_head_revisions" in both the migration environment and initialization script. This ensures consistency and better reflects the purpose of the column.
1 parent ff57007 commit 9a4335f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/migrations/env.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ class FixtureMigration(declarative_base):
5050
bind: Mapped[str] = mapped_column(String(), primary_key=True)
5151
module_name: Mapped[str] = mapped_column(String(), primary_key=True)
5252
signature: Mapped[str] = mapped_column(String(), nullable=False)
53-
alembic_revision: Mapped[str] = mapped_column(String(), nullable=True, default=str(context.get_head_revision()))
53+
alembic_head_revisions: Mapped[str] = mapped_column(
54+
String(), nullable=True, default=str(context.get_head_revision())
55+
)
5456

5557
processed_at: Mapped[datetime] = mapped_column(
5658
DateTime(), nullable=False, default=datetime.now
@@ -260,9 +262,10 @@ async def a_migrate_fixtures(
260262
cls.logger.info(
261263
f"`{fixture_module.__name__}` fixtures correctly created for `{bind_name}` bind"
262264
)
263-
except Exception as e:
265+
except Exception:
264266
cls.logger.error(
265-
f"`{fixture_module.__name__}` fixtures failed to apply to `{bind_name}` bind", exc_info=True
267+
f"`{fixture_module.__name__}` fixtures failed to apply to `{bind_name}` bind",
268+
exc_info=True,
266269
)
267270
await session.rollback()
268271

@@ -397,8 +400,10 @@ async def run_migrations_online() -> None:
397400
for name, rec in engines.items():
398401
logger.info(f"Migrating database {name}")
399402
if isinstance(rec["engine"], AsyncEngine):
403+
400404
def migration_callable(*args, **kwargs):
401405
return do_run_migration(*args, name=name, **kwargs)
406+
402407
await rec["connection"].run_sync(migration_callable)
403408
else:
404409
do_run_migration(rec["connection"], name)
@@ -420,7 +425,8 @@ def migration_callable(*args, **kwargs):
420425
for name, rec in engines.items():
421426
if isinstance(rec["engine"], AsyncEngine):
422427
await FixtureHandler.a_migrate_fixtures(
423-
bind_name=name, session=async_sessionmaker(bind=rec["connection"])
428+
bind_name=name,
429+
session=async_sessionmaker(bind=rec["connection"]),
424430
)
425431
else:
426432
FixtureHandler.migrate_fixtures(

src/migrations/versions/2025-01-26-212326-52b1246eda46_initialize_fixture_tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def upgrade_default() -> None:
3030
sa.Column("bind", sa.String(), nullable=False),
3131
sa.Column("module_name", sa.String(), nullable=False),
3232
sa.Column("signature", sa.String(), nullable=False),
33-
sa.Column("alembic_revision", sa.String(), nullable=False),
33+
sa.Column("alembic_head_revisions", sa.String(), nullable=False),
3434
sa.Column("processed_at", sa.DateTime(timezone=True), nullable=False),
3535
sa.PrimaryKeyConstraint("bind", "module_name"),
3636
)

0 commit comments

Comments
 (0)