Example #1
0
def log_action(action, migration, status, when=None):
    if when == None:
        when = datetime.datetime.now()
    statement = """
        INSERT INTO dmigrations_log(action, migration, status, datetime)
        VALUES (%s, %s, %s, %s)
    """
    params = [action, migration, status, when]
    # Should work fine in transaction for SQLite3, but gives
    # logic error or database not found error?!
    if settings.DATABASE_ENGINE == 'mysql':
        _execute_in_transaction(statement, params)
    elif settings.DATABASE_ENGINE == 'sqlite3':
        _execute(statement, params)
        cursor = connection.cursor()
        cursor.cursor.connection.commit()
Example #2
0
def get_log():
    return list(_execute("""
        SELECT action, migration, status, datetime 
        FROM dmigrations_log 
        ORDER BY datetime, id"""
    ).fetchall())
Example #3
0
def init():
    """
    Create migration log if it doesn't exist
    """
    if not table_present('dmigrations_log'):
      _execute(MIGRATION_LOG_SQL)