Get current migration version :param conn: asyncpg database connection :return: current migration version, if not exists, return 0
(
conn,
)
| 28 | |
| 29 | |
| 30 | async def get_current_version( |
| 31 | conn, |
| 32 | ): |
| 33 | """ |
| 34 | Get current migration version |
| 35 | :param conn: asyncpg database connection |
| 36 | :return: current migration version, if not exists, return 0 |
| 37 | """ |
| 38 | try: |
| 39 | await create_migration_table(conn) |
| 40 | result = await conn.fetchval(f"SELECT MAX(version) FROM {MIGRATION_TABLE}") |
| 41 | return result or 0 |
| 42 | except Exception as e: |
| 43 | logger.error(f"Error fetching current version: {e}") |
| 44 | return 0 |
| 45 | |
| 46 | |
| 47 | async def apply_migration( |
no test coverage detected