예제 #1
0
static int upgrade_v0_to_v1(const char *dbname) {

    /** RESULT   : upgrades database from v0 to v1

        RETURNS  : void

        PURPOSE  :

        NOTES    :
    **/

    (void) dbname;

    //check database is open
    check_db_open(GET_CALL_INFO);

    char *sql="ALTER TABLE GAME_DATA_TABLE ADD COLUMN TEST TEXT";

    process_sql(sql, GET_CALL_INFO);

    //set the new database version
    set_db_version(1);

    fprintf(stdout,"Database upgrade from version 0 to version 1 successful\n");

    return 0;
}
예제 #2
0
//---------------------------------------------------------------------------
int SQLLiteReport::update_report_table()
{
    const char* end = NULL;
    int ret = 0;

#define UPDATE_REPORT_TABLE_FOR_VERSION(version)                                      \
    do                                                                                \
    {                                                                                 \
        end = NULL;                                                                   \
        if (report_version > version)                                                 \
            continue;                                                                 \
        get_sql_query_for_update_report_table_v##version(query);                      \
                                                                                      \
        ret = sqlite3_prepare_v2(db, query.c_str(), query.length() + 1, &stmt, &end); \
        if (version > 1 && (ret != SQLITE_OK || !stmt || (end && *end)))              \
            return -1;                                                                \
        ret = execute();                                                              \
                                                                                      \
        if (version > 1 && ret < 0)                                                   \
            return ret;                                                               \
    } while(0);

    UPDATE_REPORT_TABLE_FOR_VERSION(0);
    UPDATE_REPORT_TABLE_FOR_VERSION(1);
    UPDATE_REPORT_TABLE_FOR_VERSION(2);

#undef UPDATE_REPORT_TABLE_FOR_VERSION

    return set_db_version(current_report_version);
}