Check the schema exists and matches configuration

def check_schema(self):
        """Check the schema exists and matches configuration"""
        if self.valid_schema:
            return
        config = self.config
        metadata = self.metadata()
        if 'current_version' not in metadata:
            raise GaugedSchemaError('Gauged schema not found, '
                                    'try a gauged.sync()')
        if metadata['current_version'] != Gauged.VERSION:
            msg = 'The schema is version %s while this Gauged is version %s. '
            msg += 'Try upgrading Gauged and/or running gauged_migrate.py'
            msg = msg % (metadata['current_version'], Gauged.VERSION)
            raise GaugedVersionMismatchError(msg)
        expected_block_size = '%s/%s' % (config.block_size, config.resolution)
        block_size = '%s/%s' % (metadata['block_size'], metadata['resolution'])
        if block_size != expected_block_size:
            msg = 'Expected %s and got %s' % (expected_block_size, block_size)
            warn(msg, GaugedBlockSizeMismatch)
        self.valid_schema = True