src/dirbs/cli/db.py
def check(ctx):
    """Checks whether DB schema matches software DB version."""
    config = common.ensure_config(ctx)
    db_config = config.db_config

    logger = logging.getLogger('dirbs.db')
    logger.info('Querying DB schema version for DB %s on host %s',
                db_config.database,
                db_config.host)

    with utils.create_db_connection(db_config) as conn:
        version = utils.query_db_schema_version(conn)
        wl_version = utils.query_wl_db_schema_version(conn)

    logger.info('Code schema version: %d', code_db_schema_version)
    if version is None:
        logger.error('DB has not been clean installed. Maybe this DB pre-dates the version checking?')
        logger.error('DB schema version unknown.')
        # Exit code is used to determine if schema has(exit code:0) or has not(exit code:1) been installed.
        # Non-zero exit code triggers installation of schema at entrypoint of processing container.
        sys.exit(1)
    else:
        logger.info('DB schema version: %s', str(version))
        logger.info('Whitelist schema version: %s', str(wl_version))

        if version < code_db_schema_version:
            logger.error('DB schema older than code.')
        elif version > code_db_schema_version:
            logger.error('DB schema newer than code.')
        else:
            logger.info('Schema versions match between code and DB.')

        if wl_version < wl_db_schema_version:
            logger.error('Whitelist schema older then code.')
        elif wl_version > wl_db_schema_version:
            logger.error('Whitelist schema newer then code.')
        else:
            logger.info('Whitelist Schema versions match between code and DB.')
Checks whether DB schema matches software DB version.
Checks whether DB schema matches software DB version.
Checks whether DB schema matches software DB version .
def check(ctx):
    config = common.ensure_config(ctx)
    db_config = config.db_config
    logger = logging.getLogger('dirbs.db')
    logger.info('Querying DB schema version for DB %s on host %s',
                db_config.database,
                db_config.host)
    with utils.create_db_connection(db_config) as conn:
        version = utils.query_db_schema_version(conn)
        wl_version = utils.query_wl_db_schema_version(conn)
    logger.info('Code schema version: %d', code_db_schema_version)
    if version is None:
        logger.error('DB has not been clean installed. Maybe this DB pre-dates the version checking?')
        logger.error('DB schema version unknown.')
        sys.exit(1)
    else:
        logger.info('DB schema version: %s', str(version))
        logger.info('Whitelist schema version: %s', str(wl_version))
        if version < code_db_schema_version:
            logger.error('DB schema older than code.')
        elif version > code_db_schema_version:
            logger.error('DB schema newer than code.')
        else:
            logger.info('Schema versions match between code and DB.')
        if wl_version < wl_db_schema_version:
            logger.error('Whitelist schema older then code.')
        elif wl_version > wl_db_schema_version:
            logger.error('Whitelist schema newer then code.')
        else:
            logger.info('Whitelist Schema versions match between code and DB.')
def check ( ctx ) : config = common . ensure_config ( ctx ) db_config = config . db_config logger = logging . getLogger ( 'dirbs.db' ) logger . info ( 'Querying DB schema version for DB %s on host %s' , db_config . database , db_config . host ) with utils . create_db_connection ( db_config ) as conn : version = utils . query_db_schema_version ( conn ) wl_version = utils . query_wl_db_schema_version ( conn ) logger . info ( 'Code schema version: %d' , code_db_schema_version ) if version is None : logger . error ( 'DB has not been clean installed. Maybe this DB pre-dates the version checking?' ) logger . error ( 'DB schema version unknown.' ) sys . exit ( 1 ) else : logger . info ( 'DB schema version: %s' , str ( version ) ) logger . info ( 'Whitelist schema version: %s' , str ( wl_version ) ) if version < code_db_schema_version : logger . error ( 'DB schema older than code.' ) elif version > code_db_schema_version : logger . error ( 'DB schema newer than code.' ) else : logger . info ( 'Schema versions match between code and DB.' ) if wl_version < wl_db_schema_version : logger . error ( 'Whitelist schema older then code.' ) elif wl_version > wl_db_schema_version : logger . error ( 'Whitelist schema newer then code.' ) else : logger . info ( 'Whitelist Schema versions match between code and DB.' )
Checks whether DB schema matches software DB version.
Checks whether DB schema matches software DB version .
"""Checks whether DB schema matches software DB version.""" # Exit code is used to determine if schema has(exit code:0) or has not(exit code:1) been installed. # Non-zero exit code triggers installation of schema at entrypoint of processing container.
ctx