'Get global policy stats for the account.
:param do_migrations: boolean, if True the policy stat dicts will
always include the \'container_count\' key;
otherwise it may be omitted on legacy databases
until they are migrated.
:returns: dict of policy stats where the key is the policy index and
the value is a dictionary like {\'object_count\': M,
\'bytes_used\': N, \'container_count\': L}'

def get_policy_stats(self, do_migrations=False):

    columns = ['storage_policy_index', 'container_count', 'object_count', 'bytes_used']
    def run_query():
        return conn.execute(('\n                                                                SELECT    %s\n                                                                FROM    policy_stat\n                                                                ' % ',    '.join(columns))).fetchall()
    self._commit_puts_stale_ok()
    info = []
    with self.get() as conn:
        try:
            info = run_query()
        except sqlite3.OperationalError as err:
            if ('no    such    column:    container_count' in str(err)):
                if do_migrations:
                    self._migrate_add_container_count(conn)
                else:
                    columns.remove('container_count')
                info = run_query()
            elif ('no    such    table:    policy_stat' not in str(err)):
                raise
    policy_stats = {}
    for row in info:
        stats = dict(row)
        key = stats.pop('storage_policy_index')
        policy_stats[key] = stats
    return policy_stats
