src/quagen/migrator.py
def migrate(schema="quagen/sql/schema.sql"):
    """
    Installs the database schema (if missing) and runs any outstanding SQL
    migrations.

    Args:
        schema (string): Path to database schema SQL
    """
    logging.info("Running database migrations")

    # If the game table is missing, we'll assume the entire schema is missing.
    # We'd be in a pretty funky state if this wasn't the case.
    try:
        db.query("SELECT game_id FROM game LIMIT 1")
    # pylint: disable=no-member
    except psycopg2.errors.UndefinedTable:
        logging.info("Schema missing, running database init")
        connection = db.get_connection()
        cursor = connection.cursor()
        cursor.execute(open(schema, "r").read())
        connection.commit()

    logging.info("Database up to date")

    Installs the database schema (if missing) and runs any outstanding SQL
    migrations.

    Args:
        schema (string): Path to database schema SQL
    
Installs the database schema (if missing) and runs any outstanding SQL
migrations.
Installs the database schema ( if missing ) and runs any outstanding SQL migrations .
def migrate(schema="quagen/sql/schema.sql"):
    logging.info("Running database migrations")
    try:
        db.query("SELECT game_id FROM game LIMIT 1")
    except psycopg2.errors.UndefinedTable:
        logging.info("Schema missing, running database init")
        connection = db.get_connection()
        cursor = connection.cursor()
        cursor.execute(open(schema, "r").read())
        connection.commit()
    logging.info("Database up to date")
def migrate ( schema = "quagen/sql/schema.sql" ) : logging . info ( "Running database migrations" ) try : db . query ( "SELECT game_id FROM game LIMIT 1" ) except psycopg2 . errors . UndefinedTable : logging . info ( "Schema missing, running database init" ) connection = db . get_connection ( ) cursor = connection . cursor ( ) cursor . execute ( open ( schema , "r" ) . read ( ) ) connection . commit ( ) logging . info ( "Database up to date" )
Installs the database schema (if missing) and runs any outstanding SQL
migrations.
Installs the database schema ( if missing ) and runs any outstanding SQL migrations .
"""
    Installs the database schema (if missing) and runs any outstanding SQL
    migrations.

    Args:
        schema (string): Path to database schema SQL
    """ # If the game table is missing, we'll assume the entire schema is missing. # We'd be in a pretty funky state if this wasn't the case. # pylint: disable=no-member
schema
Path to database schema SQL
Path to database schema SQL