예제 #1
0
def _log(session, message, code=models.LogCodes.info):
    try:
        log = models.Log(code=code, description=message, migration_head=migration.get_remote_head_id(session))
        session.add(log)
        session.commit()
    except:
        session.rollbac()
예제 #2
0
def _set_migration_head(session):
    """
    Set the migration log to the current release.
    This has to be set on new database instances to make the logs 
    point to the correct migration version. Otherwise 
    the migration would run conflicting code. 

    """
    local_head = migration.get_local_head_id()
    try:
        remote_head = migration.get_remote_head_id(session)
    except:
        remote_head = 0
    if local_head > remote_head:
        log = models.Log(
            code=models.LogCodes.migration, 
            description='Bump HEAD after clean install using metacatalog==%s' %  __version__, 
            migration_head=local_head)
        session.add(log)
        session.commit()
예제 #3
0
def current_head(args):
    session = connect(args)

    head = migration.get_remote_head_id(session)

    cprint(args, 'Current database revision: %d' % head)