src/pEpEngine.c
branchENGINE-559
changeset 3727 d926613299bf
parent 3699 e2aa6fdbd20b
child 3728 3e8c536a1634
     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.