text stringlengths 0 357 |
|---|
dbversion = NEW_DB_VERSION; |
dc_sqlite3_set_config_int(sql, "dbversion", NEW_DB_VERSION); |
} |
#undef NEW_DB_VERSION |
#define NEW_DB_VERSION 53 |
if (dbversion < NEW_DB_VERSION) |
{ |
// the messages containing _only_ locations |
// are also added to the database as _hidden_. |
dc_sqlite3_execute(sql, "CREATE TABLE locations (" |
" id INTEGER PRIMARY KEY AUTOINCREMENT," |
" latitude REAL DEFAULT 0.0," |
" longitude REAL DEFAULT 0.0," |
" accuracy REAL DEFAULT 0.0," |
" timestamp INTEGER DEFAULT 0," |
" chat_id INTEGER DEFAULT 0," |
" from_id INTEGER DEFAULT 0);"); |
dc_sqlite3_execute(sql, "CREATE INDEX locations_index1 ON locations (from_id);"); |
dc_sqlite3_execute(sql, "CREATE INDEX locations_index2 ON locations (timestamp);"); |
dc_sqlite3_execute(sql, "ALTER TABLE chats ADD COLUMN locations_send_begin INTEGER DEFAULT 0;"); |
dc_sqlite3_execute(sql, "ALTER TABLE chats ADD COLUMN locations_send_until INTEGER DEFAULT 0;"); |
dc_sqlite3_execute(sql, "ALTER TABLE chats ADD COLUMN locations_last_sent INTEGER DEFAULT 0;"); |
dc_sqlite3_execute(sql, "CREATE INDEX chats_index3 ON chats (locations_send_until);"); |
dbversion = NEW_DB_VERSION; |
dc_sqlite3_set_config_int(sql, "dbversion", NEW_DB_VERSION); |
} |
#undef NEW_DB_VERSION |
#define NEW_DB_VERSION 54 |
if (dbversion < NEW_DB_VERSION) |
{ |
dc_sqlite3_execute(sql, "ALTER TABLE msgs ADD COLUMN location_id INTEGER DEFAULT 0;"); |
dc_sqlite3_execute(sql, "CREATE INDEX msgs_index6 ON msgs (location_id);"); |
dbversion = NEW_DB_VERSION; |
dc_sqlite3_set_config_int(sql, "dbversion", NEW_DB_VERSION); |
} |
#undef NEW_DB_VERSION |
#define NEW_DB_VERSION 55 |
if (dbversion < NEW_DB_VERSION) |
{ |
dc_sqlite3_execute(sql, "ALTER TABLE locations ADD COLUMN independent INTEGER DEFAULT 0;"); |
dbversion = NEW_DB_VERSION; |
dc_sqlite3_set_config_int(sql, "dbversion", NEW_DB_VERSION); |
} |
#undef NEW_DB_VERSION |
// (2) updates that require high-level objects |
// (the structure is complete now and all objects are usable) |
// -------------------------------------------------------------------- |
if (recalc_fingerprints) |
{ |
sqlite3_stmt* stmt = dc_sqlite3_prepare(sql, "SELECT addr FROM acpeerstates;"); |
while (sqlite3_step(stmt)==SQLITE_ROW) { |
dc_apeerstate_t* peerstate = dc_apeerstate_new(sql->context); |
if (dc_apeerstate_load_by_addr(peerstate, sql, (const char*)sqlite3_column_text(stmt, 0)) |
&& dc_apeerstate_recalc_fingerprint(peerstate)) { |
dc_apeerstate_save_to_db(peerstate, sql, 0/*don't create*/); |
} |
dc_apeerstate_unref(peerstate); |
} |
sqlite3_finalize(stmt); |
} |
if (update_file_paths) |
{ |
// versions before 2018-08 save the absolute paths in the database files at "param.f="; |
// for newer versions, we copy files always to the blob directory and store relative paths. |
// this snippet converts older databases and can be removed after some time. |
char* repl_from = dc_sqlite3_get_config(sql, "backup_for", sql->context->blobdir); |
dc_ensure_no_slash(repl_from); |
assert('f'==DC_PARAM_FILE); |
char* q3 = sqlite3_mprintf("UPDATE msgs SET param=replace(param, 'f=%q/', 'f=$BLOBDIR/');", repl_from); |
dc_sqlite3_execute(sql, q3); |
sqlite3_free(q3); |
assert('i'==DC_PARAM_PROFILE_IMAGE); |
q3 = sqlite3_mprintf("UPDATE chats SET param=replace(param, 'i=%q/', 'i=$BLOBDIR/');", repl_from); |
dc_sqlite3_execute(sql, q3); |
sqlite3_free(q3); |
free(repl_from); |
dc_sqlite3_set_config(sql, "backup_for", NULL); |
} |
} |
dc_log_info(sql->context, 0, "Opened \"%s\".", dbfile); |
return 1; |
cleanup: |
dc_sqlite3_close(sql); |
return 0; |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.