'Sync the database up to the most recent version.'

@args('--version', metavar='<version>', help='Database    version')
@args('--local_cell', action='store_true', help='Only    sync    db    in    the    local    cell:    do    not    attempt    to    fan-outto    all    cells')
def sync(self, version=None, local_cell=False):

    if (not local_cell):
        ctxt = context.RequestContext()
        try:
            cell_mapping = objects.CellMapping.get_by_uuid(ctxt, objects.CellMapping.CELL0_UUID)
            with context.target_cell(ctxt, cell_mapping) as cctxt:
                migration.db_sync(version, context=cctxt)
        except exception.CellMappingNotFound:
            print(_('WARNING:    cell0    mapping    not    found    -    not    syncing    cell0.'))
        except Exception:
            print(_('ERROR:    could    not    access    cell    mapping    database    -    has    api    db    been    created?'))
    return migration.db_sync(version)
