def handle_schema_errors(conn, alembic_config, msg=None): try: yield except (db.exc.OperationalError, db.exc.ProgrammingError, db.exc.StatementError): db_revision, head_revision = (None, None) try: with quieten(): db_revision, head_revision = check_alembic_revision( alembic_config, conn) # If exceptions were raised during the revision check, we want to swallow them and # allow the original exception to fall through except Exception: pass if db_revision != head_revision: # Disable exception chaining since the original exception is included in the # message, and the fact that the instance needs migrating should be the first # thing the user sees raise DagsterInstanceMigrationRequired( msg=msg, db_revision=db_revision, head_revision=head_revision, original_exc_info=sys.exc_info(), ) from None raise
def handle_schema_errors(conn, alembic_config, msg=None): try: yield except (db.exc.OperationalError, db.exc.ProgrammingError, db.exc.StatementError): db_revision, head_revision = (None, None) try: with quieten(): db_revision, head_revision = check_alembic_revision( alembic_config, conn) # If exceptions were raised during the revision check, we want to swallow them and # allow the original exception to fall through except Exception: # pylint: disable=broad-except pass if db_revision != head_revision: raise DagsterInstanceMigrationRequired( msg=msg, db_revision=db_revision, head_revision=head_revision, original_exc_info=sys.exc_info(), ) raise