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



##########
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:
       Actually I think `run_migrations` will take care of this:
   ```python
   ...
           if self.purge:
               if self.as_sql:
                   raise util.CommandError("Can't use --purge with --sql mode")
               self._ensure_version_table(purge=True)
               heads = ()
           else:
               heads = self.get_current_heads()
   
               if not self.as_sql and not heads:
                   self._ensure_version_table()
   ...
   ```
   Which case is missing @anitakar?
   
   But, I see, you need to ensure that before locking the table.




----------------------------------------------------------------
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