feluelle commented on a change in pull request #10151:
URL: https://github.com/apache/airflow/pull/10151#discussion_r469979521



##########
File path: airflow/migrations/env.py
##########
@@ -98,7 +98,23 @@ def run_migrations_online():
         )
 
         with context.begin_transaction():
+            if connection.dialect.name == 'mysql' and \
+                    connection.dialect.server_version_info >= (5, 6):
+                connection.execute(
+                    "select GET_LOCK('alembic',1800);"
+                )
+            if connection.dialect.name == 'postgresql':
+                context._ensure_version_table()  # pylint: 
disable=protected-access

Review comment:
       ```suggestion
                   context.get_context()._ensure_version_table()  # pylint: 
disable=protected-access
   ```
   
   Because the `_ensure_version_table` function is only available in the 
`MigrationContext` you have to get this context from the (environment) context 
you are in.
   
   From the `MigrationContext` docs:
   ```
       When inside the ``env.py`` script, the :class:`.MigrationContext`
       is available via the
       :meth:`.EnvironmentContext.get_context` method,
       which is available at ``alembic.context``::
   
           # from within env.py script
           from alembic import context
           migration_context = context.get_context()
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to