Example #1
0
bool
DatabaseImpl::updateSchema( int currentver )
{
    qDebug() << "Create tables... old version is" << currentver;
    QString sql( get_tomahawk_sql() );
    QStringList statements = sql.split( ";", QString::SkipEmptyParts );
    db.transaction();

    foreach( const QString& sl, statements )
    {
        QString s( sl.trimmed() );
        if( s.length() == 0 )
            continue;

        qDebug() << "Executing:" << s;
        TomahawkSqlQuery query = newquery();
        query.exec( s );
    }
Example #2
0
bool
DatabaseImpl::updateSchema( int oldVersion )
{
    // we are called here with the old database. we must migrate it to the CURRENT_SCHEMA_VERSION from the oldVersion
    if ( oldVersion == 0 ) // empty database, so create our tables and stuff
    {
        tLog() << "Create tables... old version is" << oldVersion;
        QString sql( get_tomahawk_sql() );
        QStringList statements = sql.split( ";", QString::SkipEmptyParts );
        m_db.transaction();

        foreach ( const QString& sl, statements )
        {
            QString s( sl.trimmed() );
            if ( s.length() == 0 )
                continue;

            tLog() << "Executing:" << s;
            TomahawkSqlQuery query = newquery();
            query.exec( s );
        }