ENGINE-559: modified DDL version to 12, added pep_version column to identity (and put in the upgrade code) ENGINE-559
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Fri, 17 May 2019 17:05:47 +0200
branchENGINE-559
changeset 3727d926613299bf
parent 3726 14f9e0f35945
child 3728 3e8c536a1634
ENGINE-559: modified DDL version to 12, added pep_version column to identity (and put in the upgrade code)
src/pEpEngine.c
src/pEpEngine.h
     1.1 --- a/src/pEpEngine.c	Fri May 17 16:35:36 2019 +0200
     1.2 +++ b/src/pEpEngine.c	Fri May 17 17:05:47 2019 +0200
     1.3 @@ -904,7 +904,7 @@
     1.4      sqlite3_busy_timeout(_session->system_db, 1000);
     1.5  
     1.6  // increment this when patching DDL
     1.7 -#define _DDL_USER_VERSION "11"
     1.8 +#define _DDL_USER_VERSION "12"
     1.9  
    1.10      if (in_first) {
    1.11  
    1.12 @@ -965,6 +965,7 @@
    1.13                  "   comment text,\n"
    1.14                  "   flags integer default 0,\n"
    1.15                  "   is_own integer default 0,\n"
    1.16 +                "   pep_version real default 0,\n"                
    1.17                  "   timestamp integer default (datetime('now')),\n"
    1.18                  "   primary key (address, user_id)\n"
    1.19                  ");\n"
    1.20 @@ -1070,7 +1071,10 @@
    1.21          // Sometimes the user_version wasn't set correctly. 
    1.22          if (version == 1) {
    1.23              bool version_changed = true;
    1.24 -            if (db_contains_table(_session, "social_graph") > 0) {
    1.25 +            if (table_contains_column(_session, "identity", "pep_version") > 0) {
    1.26 +                version = 12;
    1.27 +            } // N.B. Version 11 was a DB internal fix; there's no identifying information, but this is only one extra exec.
    1.28 +            else if (db_contains_table(_session, "social_graph") > 0) {
    1.29                  if (!table_contains_column(_session, "person", "device_group"))
    1.30                      version = 10;
    1.31                  else
    1.32 @@ -1423,6 +1427,17 @@
    1.33                  if (status != PEP_STATUS_OK)
    1.34                      return status;
    1.35              }
    1.36 +            if (version < 12) {
    1.37 +                int_result = sqlite3_exec(
    1.38 +                    _session->db,
    1.39 +                    "alter table identity\n"
    1.40 +                    "   add column pep_version real default 0;\n",
    1.41 +                    NULL,
    1.42 +                    NULL,
    1.43 +                    NULL
    1.44 +                );
    1.45 +                assert(int_result == SQLITE_OK);                
    1.46 +            }
    1.47          }        
    1.48          else { 
    1.49              // Version from DB was 0, it means this is initial setup.
     2.1 --- a/src/pEpEngine.h	Fri May 17 16:35:36 2019 +0200
     2.2 +++ b/src/pEpEngine.h	Fri May 17 17:05:47 2019 +0200
     2.3 @@ -630,6 +630,8 @@
     2.4      PEP_comm_type comm_type;    // type of communication with this ID
     2.5      char lang[3];               // language of conversation
     2.6                                  // ISO 639-1 ALPHA-2, last byte is 0
     2.7 +    float latest_pEp_version;   // Used to determine highest seenencryption format.
     2.8 +                                // default is 2.0 for pEp users                            
     2.9      bool me;                    // if this is the local user herself/himself
    2.10      identity_flags_t flags;     // identity_flag1 | identity_flag2 | ...
    2.11  } pEp_identity;