text stringlengths 0 357 |
|---|
dc_sqlite3_execute(sql, "CREATE TABLE msgs (id INTEGER PRIMARY KEY AUTOINCREMENT," |
" rfc724_mid TEXT DEFAULT ''," /* forever-global-unique Message-ID-string, unfortunately, this cannot be easily used to communicate via IMAP */ |
" server_folder TEXT DEFAULT ''," /* folder as used on the server, the folder will change when messages are moved around. */ |
" server_uid INTEGER DEFAULT 0," /* UID as used on the server, the UID will change when messages are moved around, unique together with validity, see RFC 3501; the validity may differ from folder to folder. We use the server_uid for "markseen" and to delete messages as we check against the message-id, we ignore the validity for these commands. */ |
" chat_id INTEGER DEFAULT 0," |
" from_id INTEGER DEFAULT 0," |
" to_id INTEGER DEFAULT 0," /* to_id is needed to allow moving messages eg. from "deaddrop" to a normal chat, may be unset */ |
" timestamp INTEGER DEFAULT 0," |
" type INTEGER DEFAULT 0," |
" state INTEGER DEFAULT 0," |
" msgrmsg INTEGER DEFAULT 1," /* does the message come from a messenger? (0=no, 1=yes, 2=no, but the message is a reply to a messenger message) */ |
" bytes INTEGER DEFAULT 0," /* not used, added in ~ v0.1.12 */ |
" txt TEXT DEFAULT ''," |
" txt_raw TEXT DEFAULT ''," |
" param TEXT DEFAULT '');"); |
dc_sqlite3_execute(sql, "CREATE INDEX msgs_index1 ON msgs (rfc724_mid);"); /* in our database, one email may be split up to several messages (eg. one per image), so the email-Message-ID may be used for several records; id is always unique */ |
dc_sqlite3_execute(sql, "CREATE INDEX msgs_index2 ON msgs (chat_id);"); |
dc_sqlite3_execute(sql, "CREATE INDEX msgs_index3 ON msgs (timestamp);"); /* for sorting */ |
dc_sqlite3_execute(sql, "CREATE INDEX msgs_index4 ON msgs (state);"); /* for selecting the count of fresh messages (as there are normally only few unread messages, an index over the chat_id is not required for _this_ purpose */ |
dc_sqlite3_execute(sql, "INSERT INTO msgs (id,msgrmsg,txt) VALUES (1,0,'marker1'), (2,0,'rsvd'), (3,0,'rsvd'), (4,0,'rsvd'), (5,0,'rsvd'), (6,0,'rsvd'), (7,0,'rsvd'), (8,0,'rsvd'), (9,0,'daymarker');"); /* make sure, the reserved IDs are not used */ |
dc_sqlite3_execute(sql, "CREATE TABLE jobs (id INTEGER PRIMARY KEY AUTOINCREMENT," |
" added_timestamp INTEGER," |
" desired_timestamp INTEGER DEFAULT 0," |
" action INTEGER," |
" foreign_id INTEGER," |
" param TEXT DEFAULT '');"); |
dc_sqlite3_execute(sql, "CREATE INDEX jobs_index1 ON jobs (desired_timestamp);"); |
if (!dc_sqlite3_table_exists(sql, "config") || !dc_sqlite3_table_exists(sql, "contacts") |
|| !dc_sqlite3_table_exists(sql, "chats") || !dc_sqlite3_table_exists(sql, "chats_contacts") |
|| !dc_sqlite3_table_exists(sql, "msgs") || !dc_sqlite3_table_exists(sql, "jobs")) |
{ |
dc_sqlite3_log_error(sql, "Cannot create tables in new database \"%s\".", dbfile); |
goto cleanup; /* cannot create the tables - maybe we cannot write? */ |
} |
dc_sqlite3_set_config_int(sql, "dbversion", 0); |
} |
else |
{ |
exists_before_update = 1; |
dbversion_before_update = dc_sqlite3_get_config_int(sql, "dbversion", 0); |
} |
// (1) update low-level database structure. |
// this should be done before updates that use high-level objects that |
// rely themselves on the low-level structure. |
// -------------------------------------------------------------------- |
int dbversion = dbversion_before_update; |
int recalc_fingerprints = 0; |
int update_file_paths = 0; |
#define NEW_DB_VERSION 1 |
if (dbversion < NEW_DB_VERSION) |
{ |
dc_sqlite3_execute(sql, "CREATE TABLE leftgrps (" |
" id INTEGER PRIMARY KEY," |
" grpid TEXT DEFAULT '');"); |
dc_sqlite3_execute(sql, "CREATE INDEX leftgrps_index1 ON leftgrps (grpid);"); |
dbversion = NEW_DB_VERSION; |
dc_sqlite3_set_config_int(sql, "dbversion", NEW_DB_VERSION); |
} |
#undef NEW_DB_VERSION |
#define NEW_DB_VERSION 2 |
if (dbversion < NEW_DB_VERSION) |
{ |
dc_sqlite3_execute(sql, "ALTER TABLE contacts ADD COLUMN authname TEXT DEFAULT '';"); |
dbversion = NEW_DB_VERSION; |
dc_sqlite3_set_config_int(sql, "dbversion", NEW_DB_VERSION); |
} |
#undef NEW_DB_VERSION |
#define NEW_DB_VERSION 7 |
if (dbversion < NEW_DB_VERSION) |
{ |
dc_sqlite3_execute(sql, "CREATE TABLE keypairs (" |
" id INTEGER PRIMARY KEY," |
" addr TEXT DEFAULT '' COLLATE NOCASE," |
" is_default INTEGER DEFAULT 0," |
" private_key," |
" public_key," |
" created INTEGER DEFAULT 0);"); |
dbversion = NEW_DB_VERSION; |
dc_sqlite3_set_config_int(sql, "dbversion", NEW_DB_VERSION); |
} |
#undef NEW_DB_VERSION |
#define NEW_DB_VERSION 10 |
if (dbversion < NEW_DB_VERSION) |
{ |
dc_sqlite3_execute(sql, "CREATE TABLE acpeerstates (" |
" id INTEGER PRIMARY KEY," |
" addr TEXT DEFAULT '' COLLATE NOCASE," /* no UNIQUE here, Autocrypt: requires the index above mail+type (type however, is not used at the moment, but to be future-proof, we do not use an index. instead we just check ourself if there is a record or not)*/ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.