kaxil commented on a change in pull request #10254:
URL: https://github.com/apache/airflow/pull/10254#discussion_r537743375
##########
File path: airflow/utils/db.py
##########
@@ -597,6 +597,68 @@ def check_migrations(timeout):
log.info('Waiting for migrations... %s second(s)', ticker)
+def check_conn_id_duplicates(session=None):
+ """
+ Check unique conn_id in connection table
+ @param session: session of the sqlalchemy
+ @return: str
+ """
+ dups = []
+ try:
+ dups = session.query(Connection, func.count(Connection.conn_id)) \
+ .group_by(Connection.conn_id) \
+ .having(func.count(Connection.conn_id) > 1).all()
+ except (exc.OperationalError, exc.ProgrammingError):
+ # fallback if tables hasn't been created yet
+ pass
+ if dups:
+ return f'Seems you have non unique conn_id in connection table.\n' \
+ f'You have to manage those duplicate connections ' \
+ f'before upgrading the database.\n' \
+ f'Duplicated conn_id: {[dup[0] for dup in dups]}'
Review comment:
```suggestion
return 'Seems you have non unique conn_id in connection table.\n' \
'You have to manage those duplicate connections ' \
'before upgrading the database.\n' \
f'Duplicated conn_id: {[dup[0] for dup in dups]}'
```
----------------------------------------------------------------
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]