def drop_connections(dbname, engine):
    """
    Closes connections to a database to avoid any interference
    with the migration.

    Args:
        dbname (str): Name of database.
        engine (obj): Database engine.
    """
    con = engine.connect()
    con.execute('COMMIT')
    con.execute(
        """
        SELECT pg_terminate_backend(pid) 
        FROM pg_stat_activity 
        WHERE datname = '{}';"""
        .format(dbname))
    con.execute('COMMIT')
    con.close()
